---
title: Time zones
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

List of examples:

### Creating a new time zone

```csharp

// Creates a new time zone object
CMS.Globalization.TimeZoneInfo newTimezone = new CMS.Globalization.TimeZoneInfo();

// Sets the time zone properties
newTimezone.TimeZoneDisplayName = "New time zone";
newTimezone.TimeZoneName = "NewTimezone";
newTimezone.TimeZoneGMT = -12;
newTimezone.TimeZoneDaylight = true;
newTimezone.TimeZoneRuleStartRule = "MAR|SUN|1|LAST|3|0|1";
newTimezone.TimeZoneRuleEndRule = "OCT|SUN|1|LAST|3|0|0";

// Saves the new time zone into the database
CMS.Globalization.TimeZoneInfo.Provider.Set(newTimezone);

```

[> Back to list of examples](#toc)

### Updating a time zone

```csharp

// Gets the time zone
CMS.Globalization.TimeZoneInfo updateTimezone = CMS.Globalization.TimeZoneInfo.Provider.Get("NewTimezone");
if (updateTimezone != null)
{
    // Updates the time zone properties
    updateTimezone.TimeZoneDisplayName = updateTimezone.TimeZoneDisplayName.ToLower();

    // Saves the changes to the database
    CMS.Globalization.TimeZoneInfo.Provider.Set(updateTimezone);
}

```

[> Back to list of examples](#toc)

### Updating multiple time zones

```csharp

// Prepares the where condition
string where = "TimeZoneName LIKE N'NewTimezone%'";

// Gets all time zones whose name starts with 'NewTimezone'
var timezones = CMS.Globalization.TimeZoneInfo.Provider.Get().Where(where);         

// Loops through the individual time zones
foreach (CMS.Globalization.TimeZoneInfo timezone in timezones)
{               
    // Updates the time zone's properties
    timezone.TimeZoneDisplayName = timezone.TimeZoneDisplayName.ToUpper();

    // Saves the changes to the database
    CMS.Globalization.TimeZoneInfo.Provider.Set(timezone);
}

```

[> Back to list of examples](#toc)

### Deleting a time zone

```csharp

// Gets the time zone
CMS.Globalization.TimeZoneInfo deleteTimezone = CMS.Globalization.TimeZoneInfo.Provider.Get("NewTimezone");

if (deleteTimezone != null)
{
    // Deletes the time zone
    CMS.Globalization.TimeZoneInfo.Provider.Delete(deleteTimezone);
}

```

[> Back to list of examples](#toc)

### Converting time to the current user's time zone

```csharp

// Gets the current user
UserInfo user = UserInfoProvider.GetFullUserInfo(MembershipContext.AuthenticatedUser.UserID);

// Checks that the user exists
if (user != null)
{
    // Gets the current time converted to the user's time zone
    DateTime convertedTime = TimeZoneHelper.ConvertToUserDateTime(DateTime.Now, user);
}

```

[> Back to list of examples](#toc)
