I am currently in the UTC -6 Central Time zone. TimeZoneInfo.Local.BaseUtcOffset returns -6, but DateTimeOffset.Now.Offset returns -5. I am at a loss as to why these would be different, and I can find no documentation that would explain this. Does one respect daylight savings time and the other does not?
If I perform someDateTimeOffset.UtcDateTime.ToLocalTme(), I get a DateTime offset by -6 hours as well.
I am currently in the UTC -6 Central Time zone. TimeZoneInfo.Local.BaseUtcOffset returns -6, but
Share
As per the documentation for
TimeZoneInfo.BaseUtcOffset:and
Whereas
DateTimeOffset.Now.Offsetreturns the different between the current time in the local time zone and UTC. Not the current time zone’s standard time. Central Time is observing daylight saving time at the moment, hence the discrepancy.The documentation also gives you guidance about what to use if you want to get the offset at any particular time from a
TimeZoneInfo:Well that will depend on exactly what value
someDateTimeOffsethas. For example, if it’s in winter time, you’d see a 6 hour offset, sure.