Web Connection
GetUTCTime returns wrong UTC datetime for future dates
Gravatar is a globally recognized avatar based on your email address. GetUTCTime returns wrong UTC datetime for future dates
  Chris Vesper
  All
  Oct 9, 2020 @ 03:00pm

It appears that GetUTCTime() will return the wrong UTC time if it is given a future date where DST is active, if DST is not currently active. And vice-versa.

On a computer running in the EST time zone:

GetUTCTime(DATETIME(2020,10,9,10,0,0)) returns 10/9/2020 2:00:00 PM, which is correct
GetUTCTime(DATETIME(2020,11,9,10,0,0)) returns 11/9/2020 2:00:00 PM, which should be 11/9/2020 3:00:00 PM

GetUTCTime() relies on GetTimeZone() to return the timezone offset. GetTimeZone() calls GetTimeZoneInformation() to get the offset and also returns a value indicating if DST is active. GetTimeZone() uses this to subtract an extra hour. However, if you pass GetUTCTime() a datetime when DST is active (assuming it is not currently active) then it will compute the UTC datetime without DST since it's not currently active on the computer.

Am I using GetUTCTime() correctly? Maybe I have an older verison?

Gravatar is a globally recognized avatar based on your email address. re: GetUTCTime returns wrong UTC datetime for future dates
  Rick Strahl
  Chris Vesper
  Oct 10, 2020 @ 02:39pm

Hmmm... I don't see that:

Make sure you are on the latest version. Some time ago we switched to using .NET to handle the conversion which should correctly account for the DST of dates in the current timezone.

It's possible this may not have made it into the client tools yet - but will be in the next update. Check 7.14 though.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: GetUTCTime returns wrong UTC datetime for future dates
  Chris Vesper
  Rick Strahl
  Oct 12, 2020 @ 07:52am

It was definitely an older version of GetUTCTime()

© 1996-2020