This topic describes the syntax, description, parameters, and response parameters of time functions. This topic also provides examples of these functions.
today
- Syntax:
today()
. - Description
Queries the current date in the format of yyyy-mm-dd.
- Parameters
N/A
- Response parameters
Returns the current date in an array in the format of yyyy-mm-dd.
- Example
Outputsay(concat('today:', today()))
today:2019-05-23
time
- Syntax:
time()
. - Description
Queries the current UNIX timestamp, excluding the fractional part of milliseconds. Unit: seconds.
- Parameters
N/A
- Response parameters
Returns the current UNIX timestamp.
- Example
Outputsay(concat('time:', time()))
time:1559109666
now
- Syntax:
now()
. - Description
Queries the current UNIX timestamp, including the fractional part of milliseconds. Unit: seconds.
- Parameters
N/A
- Response parameters
Returns the current UNIX timestamp.
- Example
Outputsay(concat('now:', now()))
now:1559109666.644
localtime
- Syntax:
localtime()
. - Description
Queries the current date and time in the format of yyyy-mm-dd hh: mm: ss.
- Parameters
N/A
- Response parameters
Returns the current UTC in an array in the format of yyyy-mm-dd hh:mm:ss.
- Example
Outputsay(concat('localtime:', localtime()))
localtime:2019-05-29 14:02:41
utctime
- Syntax:
utctime()
. - Description
Queries the current UTC time in the format of yyyy-mm-dd hh:mm:ss.
- Parameters
N/A
- Response parameters
Returns the current UTC time in an array in the format of yyyy-mm-dd hh:mm:ss.
- Example
Outputsay(concat('utctime:', utctime()))
utctime:2019-05-29 06:02:41
cookie_time
- Syntax:
cookie_time(sec)
. - Description
Generates a time string in the cookie time format based on a UNIX timestamp.
- Parameters
sec: the UNIX timestamp. To query the UNIX timestamp, you can call the
time()
function. - Response parameters
Returns a time string in the cookie time format based on the UNIX timestamp specified by the
sec
parameter. - Example
Outputsay(concat('cookie_time:', cookie_time(time())))
cookie_time:Wed, 29-May-19 06:02:41 GMT
http_time
- Syntax:
http_time(sec)
. - Description
Generates a time string in the HTTP header time format based on a UNIX timestamp. For example, this function can generate the time displayed for the Last-Modified field in the HTTP header.
- Parameters
sec: the UNIX timestamp. To query the UNIX timestamp, you can call the
time()
function. - Response parameters
Returns a time string in the HTTP header time format based on the UNIX timestamp specified by the
sec
parameter. - Example
Outputsay(concat('http_time:', http_time(time())))
http_time:Wed, 29 May 2019 06:02:41 GMT
parse_http_time
- Syntax:
parse_http_time(str)
. - Description
Parses a time string that is in the HTTP header time format and returns the corresponding UNIX timestamp.
- Parameters
str: the time string in the HTTP header format that you want to parse. Example:
Thu, 22-Dec-10 10:20:35 GMT
. To query the time string, you can call thehttp_time()
function. - Response parameters
If the function succeeds, a UNIX timestamp is returned. Otherwise,
false
is returned. - Example
Outputsay(concat('parse_http_time:', parse_http_time(http_time(time()))))
parse_http_time:1559109761
UNIXtime
- Syntax:
unixtime(year, month, day, hour, min, sec)
. - Description
Generates and returns a UNIX timestamp based on the provided values of the year, month, day, hour, min, and sec parameters.
- Parameters
- year: specifies the year.
- month: specifies the month.
- day: specifies the day.
- hour: specifies the hour.
- min: specifies the minute.
- sec: specifies the second.
- Response parameters
Returns a UNIX timestamp.
- Example
Outputt = UNIXtime(1970, 1, 1, 8, 0, 0) say(concat('UNIXtime()=', t))
UNIXtime()=0