Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert time between timezones (UTC to EDT)?

Tags:

timezone

c#

I need to have a common function to convert UTC time to EDT. I have a server in India. An application in it needs to use EDT time for all time purposes.

I am using .NET 3.5.

I found this on some other forum.

DateTime eastern = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(
        DateTime.UtcNow, "Eastern Standard Time");

When i tried with "Easten Daylight Time" I got an error.

"The time zone ID 'Eastern Daylight Time' was not found on the local computer".

Please help with this or any other solution.

like image 481
Shetty Avatar asked Jun 08 '09 13:06

Shetty


People also ask

How many hours is UTC from EDT?

Time Difference between UTC and EDT Eastern Daylight Time (North America) is 4 hours behind from the UTC universal time.

How do you convert UTC time to local time zone?

(GMT-5:00) Eastern Time (US & Canada)Add the local time offset to the UTC time. For example, if your local time offset is -5:00, and if the UTC time is shown as 11:00, add -5 to 11. The time setting when adjusted for offset is 06:00 (6:00 A.M.).

Is EDT same as UTC?

The EDT is the daylight saving time (also called summertime) of the Eastern Standard Time (EST). The differences of the several time zones to each other are always specified in relation to the "Universal Time Coordinated" (UTC), the time on the prime meridian (zero longitude).

What is the UTC for Eastern time zone?

Eastern Standard Time (EST) The Eastern Standard Time is consistent with UTC -5.


1 Answers

Eastern Daylight Time isn't the name of a "full" time zone - it's "half" a time zone, effectively, always 4 hours behind UTC. (There may be proper terminology for this, but I'm not aware of it.)

Why would you want to use EDT for times which don't have daylight savings applied? If you want a custom time zone that always has the same offset to UTC, use TimeZoneInfo.CreateCustomTimeZone.

Note that if you use get the Eastern Standard timezone (TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time")) then that will still have daylight saving time applied appropriately (i.e. during summer).

For example:

TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");

// Prints True
Console.WriteLine(tzi.IsDaylightSavingTime(new DateTime(2009, 6, 1)));
// Prints False
Console.WriteLine(tzi.IsDaylightSavingTime(new DateTime(2009, 1, 1)));
like image 134
Jon Skeet Avatar answered Sep 25 '22 22:09

Jon Skeet