Sitefinity Showing the Wrong Time Offset From UTC

Posted by Community Admin on 04-Aug-2018 22:27

Sitefinity Showing the Wrong Time Offset From UTC

All Replies

Posted by Community Admin on 23-Jul-2015 00:00

Sitefinity seems to improperly calculate Date Offsets from UTC.

For example, here's a datetime stored in their system: 2015-10-21 00:30:00.000 (Make a custom field or Dynamic Content with a DateTime field).

Now let's say you want to see that field for Central Standard Time. The easiest way to do this is goto Settings->Advanced->System->UI Time Zone Config. Set the CurrentTimeZoneInfo to "Central Standard Time" (this change propogates to the basic settings for Time Zone).

Now view it in the backend. It says 20 Oct, 2015 08:30:00. Well, according to my calculations, it's actually 7:30.

Here's my test code:

string zone = "Central Standard Time";
TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById(zone);
var asdf = DateTime.Parse("2015-10-21 00:30:00.000");
DateTime dt = TimeZoneInfo.ConvertTimeFromUtc(asdf, tz);
Console.WriteLine(dt.ToString());

Am I missing something here?

This thread is closed