I had previously implemented dates in my app based off a timezone stored in the user's profile. As far as I can recall, this worked correctly when originally implemented.
All the dates stored in the database that I'm displaying are in UTC, meaning when I save dates (in C#), I use DateTime.UtcNow
.
Here is the momentjs code I'm using in Angular to render my dates with actual values:
moment.utc('2016-05-16T19:14:06.51').utcOffset('-05:00:00').format('M/D/YYYY h:mma');
The -05:00:00
offset is for Eastern Time. I'm expecting the specified UTC date above to result in the display of 3:15pm, but instead is displaying 2:15pm.
To double check I wasn't using a bad date value, I went into MS SQL Management Studio and ran SELECT GETUTCDATE()
which returned 2016-05-16 19:44:05.850
. It is currently 3:44pm, but it is rendering 2:44pm with the above momentjs code.
What is going on? Am I missing some momentjs code to handle daylight savings or something?