DATETIME
**The function DATETIME combines the information contained in a given Date, Time, and timezone (represented in a string) into a single DateTime. **
This function takes three pieces of input: a Date, a Time, and a string (describing a timezone according to its TZ database name). It returns a single DateTime, containing all information represented by the input.
Declaration
Parameters
date (required, type: Date) Any Date.
time (required, type: Time) Any Time.
time_zone (optional, type: string, default: "UTC") A string containing a timezone. Timezones must be described by their TZ database names.
Return Values
datetime (type: DateTime) A DateTime containing the information given by date, time, and time_zone.
Examples
Assuming the following examples have access to the following Date and Time values:
The following example takes the date described by example_date and the time described by example_time and creates a single DateTime with the information contained in both. Note that no timezone was specified, so the timezone of the created DateTime defaults to "UTC":
The following example is given the same Date and Time values as the example above, but the timezone is defined, not as "UTC", but as "Africa/Dar_es_Salaam". Note that this timezone is three hours ahead of UTC, but this does not impact the time information in the returned DateTime; the hour, minute, second, and millisecond values all correspond with their analogous values in example_time. The DATETIME function assumes the given time information is in the relevant timezone:
Last updated