I have a fairly large web application that is being developed using ASP.NET MVC 5 and MsSql 2008. I have +0700 UTC on my PC, but I have a different time zone on my shared hosting.
This code gives me the correct DateTime.
DateTime utcTime = DateTime.UtcNow;
string zoneID = "N. Central Asia Standard Time";
TimeZoneInfo myZone = TimeZoneInfo.FindSystemTimeZoneById(zoneID);
DateTime custDateTime = TimeZoneInfo.ConvertTimeFromUtc(utcTime, myZone);
Console.WriteLine(custDateTime.ToString());
Unfortunately, I have many places where I work with date and time. I'm afraid I forgot to change the code somewhere.
Is there an easy way to set the correct time zone for my web application?
PS All users of my application have the same time zone.
source
share