C# program to convert a time to the time in a particular time zone (TimeZoneInfo.ConvertTime() Method)
using System;
using System.Globalization;
using System.Collections.ObjectModel;
class TimeZoneInfoDemo
{
//Entry point of Program
static public void Main()
{
TimeZoneInfo easternStandardTime;
DateTime time;
DateTime convertedTime;
time= new DateTime(2015, 2, 1, 0, 21, 20, DateTimeKind.Utc);
easternStandardTime = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
convertedTime = TimeZoneInfo.ConvertTime(time, easternStandardTime);
Console.WriteLine("Time before conversion: "+ time);
Console.WriteLine("Time After conversion: "+ convertedTime);
}
}
Time before conversion: 2/1/2015 12:21:20 AM
Time After conversion: 1/31/2015 7:21:20 PM
Press any key to continue . . .
Table of Contents