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


according to multiple postings, microsoft enabled ability use application setting - website_time_zone - control timezone of web server.

to try this, set value "eastern standard time" local time zone.

on asp.net mvc razor page, added following code:

datetime.now: @datetime.now datetimeoffset.now: @datetimeoffset.now datetime.utcnow: @datetimeoffset.utcnow 

when ran last night @ 5:10:07pm eastern standard time, gave following output:

datetime.now: 6/18/2015 5:10:07 pm datetimeoffset.now: 6/18/2015 5:10:07 pm +00:00 datetime.utcnow: 6/18/2015 9:10:07 pm 

as can see, setting correctly allowed datetime.now return correct value in timezone rather utc azure websites/web apps do. datetime.utcnow has returned correct value obvious reasons.

however, datetimeoffset.now returns local time, offset of +00:00 - if clock changed rather timezone. occurs though documentation says (emphasis mine):

gets datetimeoffset object set current date , time on current computer, with offset set local time's offset coordinated universal time (utc).

so happening website_time_zone setting impacts datetime.now not impact datetimeoffset.now? , there way can around that?

as point of clarification, don't want change time zone on server. working on proper timezone independent solution. i'm still curious why happens way does.

well me works right now. if not working make sure set right value

  1. open regedit
  2. search "time zones"
  3. check how zone written. instance zone "eastern est (+2)" , in registry name "e. europe standard time"

so added app settings in azure app "website_time_zone: e. europe standard time" , works.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -