The function NOW returns a DateTime corresponding with the date and moment the function was called.
This function requires no input. It returns a DateTime indicating the date and time at the moment the function was called. By default, the DateTime will be in the UTC timezone, though NOW also accepts an optional input String specifying the timezone of the output; if this is provided, NOW will return the DateTime in the specified timezone.
Declaration
NOW(time_zone) -> current_datetime
Parameters
time_zone (optional, type: string, default: UTC)
A string representation of the timezone.
TZ Database Names are the timezone representations NOW is able to parse.
Return Values
current_datetime (type: Date)
The present date and time.
Examples
Due to the very nature of the NOW function, it will return different output depending on when it is called. For the sake of demonstration, imagine all of the following examples were executed at 10:30 PM (or 22:30 in military time) UTC on April 20, 2021.
The following example returns the date in UTC. Note that no input is given to the NOW function; UTC is the default timezone:
NOW() -> {
date: {
day: 20,
month: 4,
year: 2021
},
time: {
hour: 22,
minute: 30,
second: 0,
millisecond: 0
},
timeZone: "UTC"
}
The Antarctica/Syowa timezone is three hours ahead of UTC. At 10:30 PM UTC, it is already early morning in the Antarctica/Syowa timezone. The following example requests the date and time in the Antarctica/Syowa timezone. Note that it outputs a DateTime a day ahead of the previous example, even though, according to our hypothetical, both functions were called at the exact same time:
NOW("Antarctica/Syowa") -> {
date: {
day: 21,
month: 4,
year: 2021
},
time: {
hour: 1,
minute: 30,
second: 0,
millisecond: 0
},
timeZone: "Antarctica/Syowa"
}