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...
Greenwich Mean Time is 5 hours ahead of Eastern Standard Time.
Greenwich Mean Time is 4 hours ahead of Eastern Daylight Time.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With