0

I'm taking a set date/time value and converting from UTC, but timezone. I'm expecting to get the original time - 5 to be the correct time in the EST time zone, but it is off by 1 hour and only offset it by 4 hours.

string dateString = "3/15/2021 6:59 AM";
DateTime TimeDataDue = DateTime.Parse(dateString, System.Globalization.CultureInfo.InvariantCulture);

TimeZoneInfo easternZone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
var TimeDataDueEastern = TimeZoneInfo.ConvertTimeFromUtc(TimeDataDue, easternZone).Dump();

The output I get is "3/15/2021 2:59:00 AM", but I expect to get "3/15/2021 1:59:00 AM"

Any suggestions?

Thanks!

Ole V.V.
  • 81,772
  • 15
  • 137
  • 161
kalapakim
  • 3
  • 2
  • 2
    The date/time you got is correct, because it falls into DST transition (for EST that's +1 hour from March till November). Remember that a time zone = UTC offset + DST rules. – Yarik Feb 25 '21 at 04:50
  • Thank You, this makes perfect sense! – kalapakim Feb 25 '21 at 15:44

1 Answers1

0

As Yarik said in the question comments, the result you obtained is correct.

You can review the 2021 DST schedule for the US Eastern Time zone here: https://www.timeanddate.com/time/zone/usa/new-york?year=2021

screenshot 1

screnshot 2

Additionally, you'll note that easternZone.DisplayName in your code will be "(UTC-05:00) Eastern Time (US & Canada)" (assuming English). In other words, despite the time zone having the word "Standard" in its Id, it applies for the entire year including both EST and EDT periods.

Since EDT is in effect on March 15th 2021, you get a result that is four hours behind UTC.

Matt Johnson-Pint
  • 230,703
  • 74
  • 448
  • 575