Get Indian Standard Time(IST) in c#?

Viewed 30846

When i display my system date using DateTime.Now() function It gives me system date and time and works fine but when i try to run this page on my server it gives me the DateTime of Server which is outside India But i want to pick up the time of India whenever this page is executed on server. I know it is possible through Culture Info Class... Any suggestion....

3 Answers

The below code works for me:

TimeZoneInfo INDIAN_ZONE = TimeZoneInfo.FindSystemTimeZoneById("Asia/Kolkata");
DateTime indianTime =  TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, INDIAN_ZONE);
Console.WriteLine(indianTime.ToString("F"));
Related