Follow @endyourif rss Facebook LinkedIn

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

Published on Jun 7, 2017

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.

Using TimeZoneInfo.FindSystemTimeZoneById with TimeZoneInfo.ConvertTimeFromUtc

Here is the code that uses .NET's built-in functions to a from a UTC date to a specific timezone:

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

First thing we do is create a new date with UtcNow.  This of course could be any other UTC date you wish to convert.  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.

This process will also work for any other Microsoft support timezone values, e.g. you can replace "Eastern Standard Time" with "Pacific Standard Time".

If you need help finding your time zone, review Microsoft's Time Zone Index Values.

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

My Books
ASP.NET MVC 5 With Bootstrap and Knockout.js
Knockout.js Building Dynamic Client-Side Applications
20 Recipes for Programming MVC 3
20 Recipes for Programming PhoneGap
Rapid Application Development with CakePHP