Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

convert from EST/EDT to GMT

Tags:

c#

datetime

How do I convert a DateTime from EST/EDT to GMT but I don't know where the code will be ran (unknown local time zone) and also account for time savings...

like image 868
Comma Avatar asked Jul 23 '10 23:07

Comma


People also ask

Is GMT 4 or 5 hours ahead of EST?

Greenwich Mean Time is 5 hours ahead of Eastern Standard Time.

How many hours is GMT from EDT?

Greenwich Mean Time is 4 hours ahead of Eastern Daylight Time.


1 Answers

You want TimeZoneInfo.ConvertTimeToUtc(), which allows you to pass the source time zone info as a parameter. For example:

TimeZoneInfo est = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
DateTime someDateTimeInUtc = TimeZoneInfo.ConvertTimeToUtc(someDateTime, est);

I think this will automatically handle daylight-saving time, but you'll want to test it to be sure.

like image 68
JaredReisinger Avatar answered Sep 28 '22 05:09

JaredReisinger