Skip to content

Instantly share code, notes, and snippets.

@rarous
Last active December 26, 2015 02:58
Show Gist options
  • Save rarous/7082074 to your computer and use it in GitHub Desktop.
Save rarous/7082074 to your computer and use it in GitHub Desktop.
public static DateTime ToLocalTime(this DateTime utcDate, string timeZoneId) {
var timeZone = TimeZoneInfo.FindSystemTimeZoneById(timeZoneId);
var utc = new DateTimeOffset(DateTime.SpecifyKind(utcDate, DateTimeKind.Utc));
return utc.ToOffset(timeZone.GetUtcOffset(utcDate)).DateTime;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment