Changing TimeZone on Azure Web Apps Doesn't work for DateTimeOffset.Now? Changing TimeZone on Azure Web Apps Doesn't work for DateTimeOffset.Now? asp.net asp.net

Changing TimeZone on Azure Web Apps Doesn't work for DateTimeOffset.Now?


Well for me it works right now. If it is not working make sure you set right value

  1. Open regedit
  2. Search for "time zones"
  3. Check how your zone is written. For instance my zone is "Eastern EST (+2)" and in registry its name is "E. Europe Standard Time"

So I added to app settings in azure app "WEBSITE_TIME_ZONE: E. Europe Standard Time" and it works.


For those who stumble upon this question. This has been fixed for a long time now.


I am running into the same problem. Unfortunately for me, I inherited a lot of legacy code that was written specifically for Eastern Standard Time, so updating it to work with UTC is essentially not an option.

After digging into the CLR code, it seems to be due to the fact that the local time zone is looked up against the system registry. Don't see how they can properly support this without a change to the CLR code since Azure Web Apps run on shared VMs.

For the time being, I will be getting around this with the following reflection hack at site startup to trick .Net into thinking it is in the Eastern Standard Time. It's not a great solution, and most likely will break if they change the implementation of the TimeZoneInfo class, but hopefully the reason for them changing it will be to address this issue.

// rewrite local timezonevar tz = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");var fInfo = typeof(TimeZoneInfo).GetField("s_cachedData", BindingFlags.Static|BindingFlags.NonPublic);var cachedData = fInfo.GetValue(null);fInfo = cachedData.GetType().GetField("m_localTimeZone", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);fInfo.SetValue(cachedData, tz);