### Function

# GLib DateTime new

since: 2.26

#### Declaration

    GDateTime*
    g_date_time_new (
      GTimeZone* tz,
      gint year,
      gint month,
      gint day,
      gint hour,
      gint minute,
      gdouble seconds
    )

#### Description

Creates a new `GDateTime` corresponding to the given date and time in the time zone `tz`.

The `year` must be between 1 and 9999, `month` between 1 and 12 and `day` between 1 and 28, 29, 30 or 31 depending on the month and the year.

`hour` must be between 0 and 23 and `minute` must be between 0 and 59.

`seconds` must be at least 0.0 and must be strictly less than 60.0. It will be rounded down to the nearest microsecond.

If the given time is not representable in the given time zone (for example, 02:30 on March 14th 2010 in Toronto, due to daylight savings time) then the time will be rounded up to the nearest existing time (in this case, 03:00). If this matters to you then you should verify the return value for containing the same as the numbers you gave.

In the case that the given time is ambiguous in the given time zone (for example, 01:30 on November 7th 2010 in Toronto, due to daylight savings time) then the time falling within standard (ie: non-daylight) time is taken.

It not considered a programmer error for the values to this function to be out of range, but in the case that they are, the function will return `NULL`.

You should release the return value by calling `g_date_time_unref()` when you are done with it.

Available since: 2.26

#### Parameters

`tz`

  Type: `GTimeZone`

  A `GTimeZone`.

  The data is owned by the caller of the function.

`year`

  Type: `gint`

  The year component of the date.

`month`

  Type: `gint`

  The month component of the date.

`day`

  Type: `gint`

  The day component of the date.

`hour`

  Type: `gint`

  The hour component of the date.

`minute`

  Type: `gint`

  The minute component of the date.

`seconds`

  Type: `gdouble`

  The number of seconds past the minute.

#### Return value

Type: `GDateTime`

A new `GDateTime`, or `NULL`.

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