In this blog I am trying to explain the concept of TimeZone Class in C#.
A time zone is a geographical region in which the same standard time is used. You can use the TimeZone class to get information about the current time zone, and to convert times from local time to Coordinated Universal Time (UTC) or vice versa. However, you cannot use the TimeZone class to represent time zones other than the local zone or to handle date and time conversions from one time zone to another. For this purpose, use the TimeZoneInfo class. You can use this class to retrieve information on any time zone defined on the local system, to create custom time zones, and to convert times from one time zone to another.
TimeZone Example: -
You need the System.Globalization namespace for use the time zone classes.
Code description: -
1. Create a TimeZone class.
2. Start Main method.
5. Display the names for standard time and daylight saving.
6. Time for the local time zone.
7. Display the current date and time and show if they occur.
8. Display the current date and time in daylight saving time.
9. Get the current Coordinated Universal Time (UTC) and UTC.
10. Get the current Coordinated Universal Time (UTC) and UTC offset.
11. Show the current Coordinated Universal Time.
12. Show the Coordinated Universal Time offset.
13. Get the DaylightTime object for the current year.
14. Display the daylight saving time range for the current year.