C# Convert date from UTC to EST C# Convert date from UTC to EST

Every now and then I need to convert a date from Coordinated Universal Time (UTC) to Eastern Standard Time (EST).  I always found myself trying to remember: Where did I use this last?.  To avoid asking myself, I have now immortalized it on my blog. The solution leverages TimeZoneInfo.ConvertTimeFromUtc. The following will use C# convert utc to timezone and C# convert datetime to utc. This is of course not limited to EST and can be used to c# datetime utc+8 (e.g. utc to rst).


Convert time to UTC C#

Using TimeZoneInfo.FindSystemTimeZoneById with TimeZoneInfo.ConvertTimeFromUtc

Here is the C# convert utc to est using.NET's built-in functions to a from a UTC date to a specific timezone that will convert utc timestamp to local time that will use .net convert utc to specific timezone:


var timeUtc = DateTime.UtcNow;
var easternZone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
var today = TimeZoneInfo.ConvertTimeFromUtc(timeUtc, easternZone);

C# Convert zulu time

In case you're looking about how to convert to zulu time; Zulu time is actually the same as UTC it's just a military name, so if you're looking for the C# Zulu time it is the same as UTC time.

c# convert utc to est

This will convert datetime to est from UTC time zone. First thing we do is create a new date with UtcNow current utc date and time.  This of course could be any other date you wish to convert datetime to utc in c#. 

Next we found the TimeZoneInfo object relating to my time zone "Eastern Standard Time".  And finally, I call the static ConvertTimeFromUtc function in the TimeZoneInfo class supplying my UTC date and TimeZoneInfo object utc to est conversion with the .net core set timezone.

All of these examples are heavily focused on the c# get current datetime function (convert.todatetime), but be sure not to miss out on SQL Server Convert String to Date with examples.

convert utc to est c#

This process will also work for any other Microsoft support timezone values with the current universal time, e.g. you can replace "Eastern Standard Time" with "Pacific Standard Time" (utc to est c#).

This will allow you to use C# convert UTC to specific timezone as in 9am utc to est or convert utc to etc. These functions are great for date and time converter est to utc conversion.

If you need help finding your time zone how to convert utc time to local time in c# or 2 utc to est, review Microsoft's Time Zone Index Values utc to est time conversion.

Eastern daylight time (edt) - c# utc to est

When you have a date that is in est eastern standard time and you want to convert time to utc time then you will want to leverage the TimeZoneInfo.ConvertTimeToUtc on your start date and end date.

This will convert est to utc C# with the correct est format or edt format based on the time of year. If you have a different est time then the second input parameter can be a different time zones and will still convert to universal time for that time zone.

Now that you have a great understanding what is edt vs utc? UTC is what's commonly used as the name implies universal whereas edt is a timezone for people in Canada, United States, and Mexico.

Coordinated universal time (utc)

As in the example above when you want to convert your time zone from utc to est you will use the TimeZoneInfo.ConvertTimeFromUtc on your start date and end date c# datetime to utc. This is a great way to convert hours from eastern daylight time to coordinated universal time and works for any time zones that Microsoft support. This will convert utc to est C#.

Published on Jun 30, 2022

Tags: ASP.NET MVC and Web API Tutorial | c# | timezones

Related Posts

Did you enjoy this article? If you did here are some more articles that I thought you will enjoy as they are very similar to the article that you just finished reading.

Tutorials

Learn how to code in HTML, CSS, JavaScript, Python, Ruby, PHP, Java, C#, SQL, and more.

No matter the programming language you're looking to learn, I've hopefully compiled an incredible set of tutorials for you to learn; whether you are beginner or an expert, there is something for everyone to learn. Each topic I go in-depth and provide many examples throughout. I can't wait for you to dig in and improve your skillset with any of the tutorials below.