current_time
Retrieve the current time
Definition
datetime current_time(number $offset)
Retrieves the current time in the UTC time zone as a datetime object and adds $offset
hours to it.
Parameters
number $offset
The number of hours to be added to the current time. Accepts all numbers as input, but they will be rounded.
Returns
datetime
Current time in the UTC time zone after adding $offset
hours to it.
Examples
{
a: current_time(`0`),
b: current_time('0'),
c: current_time(`1`),
d: current_time(`-1`),
e: current_time(`0.51`),
f: current_time('0.5'), // Error
g: current_time(`false`),
h: current_time(`null`) // Error
{
"a": "2021-08-22T11:03:19.9528853Z",
"b": "2021-08-22T11:03:19.9528853Z",
"c": "2021-08-22T12:03:19.9528853Z",
"d": "2021-08-22T10:03:19.9528853Z",
"e": "2021-08-22T12:03:19.9528853Z",
"g": "2021-08-22T11:03:19.9528853Z"
}
Remarks
- The
$offset
is limited by the fact that the result must be between year 0 and 10000. - The argument can be a double, but will be converted to an integer. If
$offset
is a string, it must have an integer format. $offset
can be negative as well.
Updated about 1 year ago