Tuesday, August 11, 2009

TimeZoneInfo vs TimeZone

The TimeZone class is new in 3.5 . This contains the information of Time zone in the world.
E.g :
static void Main(string[] args)
TimeZoneInfo tInfo = TimeZoneInfo.FindSystemTimeZoneById("India Standard Time");
DateTime dTime = DateTime.UtcNow;
DateTime localTime = TimeZoneInfo.ConvertTimeFromUtc(dt, mountain);

MSDN link
Finding the Time Zones


TimeZone(.Net 1.0) is to get the CurrentTimeZone(ie local time zone only) . So based on local time zone only we can convert it into necessary DateTime. But in TimeZoneinfo class helps to convert into DateTime based on any TimeZone in the World.

E.g : for TimeZone

static void Main(string[] args)
TimeZone tZ = TimeZone.CurrentTimeZone;
DateTime dT = DateTime.UtcNow;


Nicole said...

I am looking for more information on different time zone, from where I can get this information........


Cash Online Get Easy cash at your door step

Anish said...

sorry for delay in my reply !!!
have you gone through this link :http://msdn.microsoft.com/en-us/library/system.timezone.aspx

What else you want to know.Ask me i will try my level best