---
title: "TimeZone Class in C#"  
description: "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 same standard time i"  
author: "Vijay Shukla"  
published: 2013-06-12  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/525/timezone-class-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# TimeZone Class in C#

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#](https://www.mindstick.com/forum/160399/how-to-create-a-custom-generic-class-in-c-sharp-provide-an-example).

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](https://www.mindstick.com/forum/2093/configurationmanager-appsettings-convert-n-to-n-why) 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](https://yourviews.mindstick.com/view/247/no-fail-policy-failing-its-purpose), use the TimeZoneInfo class. You can use this class to [retrieve](https://www.mindstick.com/forum/34400/how-to-retrieve-form-values-in-controller-action) 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 for use the time zone

##### classes.

```
 class TimeZoneDemo { static void Main() { Console.WriteLine("{0,-30}{1}", "Standard time name:",   TimeZone.CurrentTimeZone.StandardName);
 Console.WriteLine("{0,-30}{1}", "Daylight saving time name:",    TimeZone.CurrentTimeZone.DaylightName); Console.WriteLine("\n" + "{0,-30}{1:MM-dd-yyyy HH:mm}", "Current date and time:",
   DateTime.Now); Console.WriteLine("{0,-30}{1}", "Daylight saving time?",   TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.Now)); DateTime currentUTC =TimeZone.CurrentTimeZone.ToUniversalTime(DateTime.Now); TimeSpan currentOffset =TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now); Console.WriteLine("{0,-30}{1:MM-dd-yyyy HH:mm}", "Coordinated Universal Time:",   currentUTC); Console.WriteLine("{0,-30}{1}", "UTC offset:", currentOffset); DaylightTime daylight =
   TimeZone.CurrentTimeZone.GetDaylightChanges(DateTime.Now.Year); Console.WriteLine("\nDaylight saving time for year {0}:", DateTime.Now.Year); Console.WriteLine("{0:MM-dd-yyyy HH:mm} to " +"{1:MM-dd-yyyy HH:mm}, delta: {2}",
   daylight.Start, daylight.End, daylight.Delta); Console.ReadKey();
 }
 }
```

##### 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.

##### Output: -

![TimeZone Class in C#](https://www.mindstick.com/blogs/fd5dee51-29fb-465a-bc90-3b5484b00f52/images/a0bef026-5ecf-442f-ac25-08cb1dd284ca.png)

---

Original Source: https://www.mindstick.com/blog/525/timezone-class-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
