Click here to Skip to main content
15,937,779 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm having a report mailing project in that ,i have completed generation and sending mail to corresponding mail

now i have to automate it to send itself every 7 days once at 00:00:00 IST

the problem is with elastic in that data is fetching as UTC

i need to convert it to IST and send automatically

What I have tried:

This is my Fluent Scheduler
public class ScheduledJobRegistry : Registry
           public ScheduledJobRegistry()
               Schedule<MyJob>().ToRunEvery(1).Days().At(DEFULT_HOUR, DEFULT_MINUTE);

               //use test purpose (without scheduled time):

in App config
<add key="DEFULT_HOUR" value="12" />
    <add key="DEFULT_MINUTE" value="39" />

This is how convert UTC to IST (+05:30 Hrs)

var fldFromDate = DateTime.Parse("2022-08-14T18:30:00.000Z");
var fldToDate = DateTime.Parse("2022-08-21T18:29:00.000Z");
Updated 24-Aug-22 6:46am

1 solution

Not sure if I understood your question correct or not, but if you want to convert utc to ist.

This works for me :
var timeZone = TimeZoneInfo.FindSystemTimeZoneById("IST");
var utcNow = DateTime.UtcNow; // From 'elastic' in your case?
var istNow = TimeZoneInfo.ConvertTime(utcNow, timeZone);

Console.WriteLine($"UTC = {utcNow} IST {istNow}");
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900