### Method

# GLib DateTime to_timezone

since: 2.26

#### Declaration

    GDateTime*
    g_date_time_to_timezone (
      GDateTime* datetime,
      GTimeZone* tz
    )

#### Description

Create a new `GDateTime` corresponding to the same instant in time as `datetime`, but in the time zone `tz`.

This call can fail in the case that the time goes out of bounds. For example, converting 0001-01-01 00:00:00 UTC to a time zone west of Greenwich will fail (due to the year 0 being out of range).

Available since: 2.26

#### Parameters

`tz`

  Type: `GTimeZone`

  The new `GTimeZone`.

  The data is owned by the caller of the method.

#### Return value

Type: `GDateTime`

The newly created `GDateTime` which should be freed with g_date_time_unref(), or `NULL`.

The caller of the method takes ownership of the data, and is responsible for freeing it.
The return value can be `NULL`.