/// Converts UTC DateTime to Given Time Zone
public static DateTime ConvertUtcByZone(DateTime utcDateTime, string destinationTimeZoneName)
{
utcDateTime = DateTime.SpecifyKind(utcDateTime, DateTimeKind.Unspecified);
TimeZoneInfo centralZone = TimeZoneInfo.FindSystemTimeZoneById(destinationTimeZoneName);
return TimeZoneInfo.ConvertTimeFromUtc(utcDateTime, centralZone);
}
/// How to use?
ConvertUtcByZone(DateTime.UtcNow, "Central Standard Time")
No comments:
Post a Comment