What is TimeZone Object?
TimeZone object in .NET framework represents the current local time zone.
A time zone is a geographical region in which the same standard time is used. Programmer (Software Developer) can use the TimeZone class of .NET Framework to retrieve information about the current time zone and to convert local time to Coordinated Universal Time (UTC) or vice versa. Inheritance hierarchy is System.Object - > System.TimeZone.
Below is the syntax to get the local time zone and based on that the current Coordinated Universal Time (UTC) is retrieved.
TimeZone {localZone} = TimeZone.CurrentTimeZone;
DateTime {currentUTC} = localZone.ToUniversalTime( currentDate );
The format of the date and time string in time zone will be ISO-8601 as shown below.
2016-10-13T10:20:20.20Z
Date: YYYY-MM-dd, Time: hh:mm:ss.ms, Time zone: Z for UTC
There is lot of flexibility in the ISO-8601 format for example, we could have easily replaced the ‘Z’ at the end with a proper time zone offset like -0530 (India).