Micah
Micah

Reputation: 116050

Timezone issue in .NET

I'm on the east coast so my timezone is Eastern Standard Time which has an offset of -05:00:00. But I noticied when calling methods like DateTimeOffset.UtcNow and DateTime.Now.ToUniversalTime() it's only claiming that I have an offset of -04:00:00.

DateTime.Now
// 6/8/2011 8:08:26 PM

DateTime.UtcNow
// 6/9/2011 12:08:26 AM

DateTimeOffset.UtcNow
// 6/9/2011 12:08:26 AM +00:00

DateTime.Now.ToUniversalTime()
// 6/9/2011 12:08:26 AM

TimeZoneInfo.ConvertTimeToUtc(DateTime.Now)
// 6/9/2011 12:08:26 AM

TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now)
// -04:00:00

TimeZone.CurrentTimeZone.StandardName
// Eastern Standard Time

TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time").BaseUtcOffset
// -05:00:00

As you can see even though it clearly says I'm in the "Eastern Standard Time" zone it's only calculating my offset to be -05:00:00. I've verified also that my windows clock says I'm in the correct timezone. Does anyone have any idea what's going on here?

Upvotes: 1

Views: 387

Answers (2)

Owen
Owen

Reputation: 1551

Might have something to do with it being summer. Aren't you on Eastern Daylight Time now? That's UTC minus 4.

Upvotes: 8

Brian Dishaw
Brian Dishaw

Reputation: 5825

I think it's -4 because it's currently daylight savings time.

Upvotes: 3

Related Questions