---
title: "TimeZone Class in C#"  
description: "TimeZone Class in C#In this blog I am trying to explain the concept of TimeZone  Class in C#.TimeZoneA time zone is a geographical region in which the"  
author: "Vijay Shukla"  
published: 2013-06-17  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/532/timezone-class-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# TimeZone Class in C#

TimeZone [Class in C#](https://www.mindstick.com/forum/160399/how-to-create-a-custom-generic-class-in-c-sharp-provide-an-example)

In this blog I [am trying](https://answers.mindstick.com/qa/36834/which-two-programming-languages-should-i-master-in-if-i-am-trying-to-get-into-google-or-facebook) to [explain the concept](https://www.mindstick.com/forum/159605/explain-the-concept-of-unique-key-violation-error) of TimeZone Class in C#.

## TimeZone

A time zone is a geographical region in which the same [standard](https://www.mindstick.com/articles/23223/naming-convention-or-coding-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](https://answers.mindstick.com/qa/101376/who-s-the-current-wwe-universal-champion) 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.

## Syntax: -

## [SerializableAttribute]

## [ComVisibleAttribute(true)]

## public abstract class TimeZone

## TimeZone Example: -

You need the System.Globalization [namespace](https://www.mindstick.com/articles/12552/namespace) for use the time zone classes.

1. class TimeZoneDemo

2. {

3. static void Main()

4. {

5. Console.WriteLine("{0,-30}{1}", "Standard time name:",

TimeZone.CurrentTimeZone.StandardName);

6. Console.WriteLine("{0,-30}{1}", "Daylight saving time name:",

TimeZone.CurrentTimeZone.DaylightName);

7. Console.WriteLine("\n" + "{0,-30}{1:MM-dd-yyyy HH:mm}", "[Current date](https://www.mindstick.com/forum/323/find-the-day-name-and-month-name-from-current-date) and time:",

[DateTime](https://www.mindstick.com/forum/12949/how-to-validate-if-a-datetime-field-is-not-null-empty).Now);

8. Console.WriteLine("{0,-30}{1}", "Daylight saving time?",

TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.Now));

9. DateTime currentUTC =TimeZone.CurrentTimeZone.ToUniversalTime(DateTime.Now);

10. [TimeSpan](https://www.mindstick.com/forum/12692/timespan-not-working) currentOffset =TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now);

11. Console.WriteLine("{0,-30}{1:MM-dd-yyyy HH:mm}", "Coordinated Universal Time:",

currentUTC);

12. Console.WriteLine("{0,-30}{1}", "UTC offset:", currentOffset);

13. DaylightTime daylight =

TimeZone.CurrentTimeZone.GetDaylightChanges(DateTime.Now.Year);

14. Console.WriteLine("\nDaylight saving time for year {0}:", DateTime.Now.Year);

15. Console.WriteLine("{0:MM-dd-yyyy HH:mm} to " +"{1:MM-dd-yyyy HH:mm}, delta: {2}",

daylight.Start, daylight.End, daylight.Delta);

16. Console.ReadKey();

17. }

18. }

## 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](https://answers.mindstick.com/qa/113792/what-measures-has-the-indian-government-taken-to-address-inflation-in-the-current-year).

## Output: -

![TimeZone Class in C#](https://www.mindstick.com/blogs/e73b9928-4e8b-41d0-ad01-fe56eb03f7ba/images/499df368-2d9c-4f90-b536-673bda4ce484.png)

---

Original Source: https://www.mindstick.com/blog/532/timezone-class-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
