Class

# TimeZone

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

Used to identify a time zone in relationship to a Date.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                      | Type                                        | Read-Only | Shared |
|-------------------------------------------|---------------------------------------------|-----------|--------|
| `Abbreviation<timezone.abbreviation>`     | `String</api/data_types/string>`            | ✓         |        |
| `Handle<timezone.handle>`                 | `Ptr</api/data_types/additional_types/ptr>` | ✓         |        |
| `SecondsFromGMT<timezone.secondsfromgmt>` | `Integer</api/data_types/integer>`          | ✓         |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                 | Parameters                                               | Returns  | Shared |
|--------------------------------------|----------------------------------------------------------|----------|--------|
| `Constructor<timezone.constructor0>` | gmtOffsetInSeconds As `Integer</api/data_types/integer>` |          |        |
| `Constructor<timezone.constructor1>` | name As `String</api/data_types/string>`                 |          |        |
| `Current<timezone.current>`          |                                                          | TimeZone | ✓      |

## Property descriptions

<div id="timezone.abbreviation">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

TimeZone.Abbreviation

**Abbreviation** As `String</api/data_types/string>`

> The abbreviation for the time zone.
>
> This property is read-only.
>
> Get the abbreviation for the current time zone:
>
> ``` xojo
> Var tz As String
> tz = TimeZone.Current.Abbreviation
> ' tz = "America/New_York", if in US Eastern Time Zone
> ```

<div id="timezone.handle">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

TimeZone.Handle

**Handle** As `Ptr</api/data_types/additional_types/ptr>`

> A pointer to the object for use with `declares</api/language/declare>`.
>
> This property is read-only.
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This property is currently only supported for Android.
>
> </div>

<div id="timezone.secondsfromgmt">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

TimeZone.SecondsFromGMT

**SecondsFromGMT** As `Integer</api/data_types/integer>`

> The GMT offset in seconds.
>
> This property is read-only.
>
> Gets the GMT offset in seconds for the current time zone:
>
> ``` xojo
> Var gmtOffset As Integer
> gmtOffset = TimeZone.Current.SecondsFromGMT
> ' gmtOffset = -14400 (4 hours), if US Eastern Time Zone using daylight savings time, -18000 otherwise
> ```

## Method descriptions

<div id="timezone.constructor0">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

TimeZone.Constructor

**Constructor**(gmtOffsetInSeconds As `Integer</api/data_types/integer>`)

> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> `Constructors</api/language/constructor>` are special methods called when you create an object with the `New</api/language/new>` keyword and pass in the parameters above.
>
> </div>
>
> Creates a time zone using the specified GMT offset.

<div id="timezone.constructor1">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

TimeZone.Constructor

**Constructor**(name As `String</api/data_types/string>`)

> Creates a time zone using the specified name. If the name is invalid, then an `InvalidArgumentException</api/exceptions/invalidargumentexception>` is raised.
>
> Refer to the [List of tz database time zones on Wikipedia](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
>
> Create time zone for GMT:
>
> ``` xojo
> Var gmt As New TimeZone("GMT")
> Var ny As New TimeZone("America/New_York")
> Var berlin As New TimeZone("Europe/Berlin")
> Var tokyo As New TimeZone("Asia/Tokyo")
> ```

<div id="timezone.current">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

TimeZone.Current

**Current** As TimeZone

> The current time zone.
>
> Get the current time zone:
>
> ``` xojo
> Var tz As String
> tz = TimeZone.Current.Abbreviation
> ' tz = "America/New_York", if in US Eastern Time Zone
> ```

## Notes

Use any valid <span class="title-ref">TimeZone</span>. A list of common time zones is available [here](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).

## Sample code

Creates a DateTime for Berlin <span class="title-ref">TimeZone</span> that matches the local <span class="title-ref">TimeZone</span>'s hours and minutes:

``` xojo
Var d As DateTime = DateTime.Now(New TimeZone("Europe/Berlin"))
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Convert a date in the local time zone to the GMT time zone:

``` xojo
Var date1 As DateTime = New DateTime(2021, 2, 1, 13, 0, 0, 0, TimeZone.Current)
Var gmt As New TimeZone(0) ' Get GMT time zone
Var gmtDate As New DateTime(date1.SecondsFrom1970, gmt)
```

## Compatibility

|                       |     |
|-----------------------|-----|
| **Project Types**     | All |
| **Operating Systems** | All |

<div class="seealso">

`Object</api/data_types/additional_types/object>` parent class; `DateTime</api/data_types/datetime>` class

</div>
