All Products
Search
Document Center

ApsaraVideo VOD:Time functions

Last Updated:Jul 10, 2026

Provides the syntax, parameters, return values, and examples of time functions.

today

Item Description
Syntax today()
Description Returns the current date in local time. Format: yyyy-mm-dd.
Parameters None
Return value Returns the current date. Format: yyyy-mm-dd.
Examples
say(concat('today:', today()))
Output:
today:2019-05-23

time

Item Description
Syntax time()
Description Returns the current UNIX timestamp in seconds, excluding fractional milliseconds.
Note The UNIX timestamp is independent of time zones and represents the number of seconds elapsed since 00:00:00 (UTC) on January 1, 1970.
Parameters None.
Return value Returns the current UNIX timestamp.
Examples
say(concat('time:', time()))
Output:
time:1559109666

now

Item Description
Syntax now()
Description Returns the current UNIX timestamp in seconds, excluding fractional milliseconds.
Note The UNIX timestamp is independent of time zones and represents the number of seconds elapsed since 00:00:00 (UTC) on January 1, 1970.
Parameters None.
Return value Returns the current UNIX timestamp in seconds, excluding fractional milliseconds.
Examples
say(concat('now:', now()))
The following result is returned:
now:1559109666.644

localtime

Item Description
Syntax localtime()
Description Returns the current date and time in local time. Format: yyyy-mm-dd hh:mm:ss.
Parameters None.
Return value Returns the current date and time. Format: yyyy-mm-dd hh:mm:ss.
Examples
say(concat('localtime:', localtime()))
Output:
localtime:2019-05-29 14:02:41

utctime

Item Description
Syntax utctime()
Description Returns the current UTC date and time. Format: yyyy-mm-dd hh:mm:ss.
Parameters None.
Return value Returns the current UTC date and time. Format: yyyy-mm-dd hh:mm:ss.
Examples
say(concat('utctime:', utctime()))
Output:
utctime:2019-05-29 06:02:41

cookie_time

Item Description
Syntax cookie_time(sec)
Description Converts a UNIX timestamp to a GMT time string in cookie format.
Parameters sec: the UNIX timestamp to convert. You can call the time() function to obtain a UNIX timestamp.
Return value Returns a cookie-format time string based on the UNIX timestamp specified by the sec parameter.
Examples
say(concat('cookie_time:', cookie_time(time())))
Output:
cookie_time:Wed, 29-May-19 06:02:41 GMT

http_time

Item Description
Syntax http_time(sec)
Description Converts a UNIX timestamp to a GMT time string for use in HTTP headers, such as Last-Modified.
Important The generated time strings are in GMT.
Parameters sec: the UNIX timestamp to convert. You can call the time() function to obtain a UNIX timestamp.
Return value Returns an HTTP header-format time string based on the UNIX timestamp specified by the sec parameter.
Examples
say(concat('http_time:', http_time(time())))
Output:
http_time:Wed, 29 May 2019 06:02:41 GMT

parse_http_time

Item Description
Syntax parse_http_time(str)
Description Parses an HTTP header time string and returns the corresponding UNIX timestamp.
Important This function does not recognize time zones. Convert local time to GMT before passing it to this function.
Parameters str: the HTTP header time string to parse. Example: Wed, 29 May 2019 06:02:41 GMT. You can call the http_time() function to generate this string.
Return value If the function succeeds, the corresponding UNIX timestamp is returned. Otherwise, false is returned.
Examples
say(concat('parse_http_time:', parse_http_time(http_time(time()))))
Output:
parse_http_time:1559109761

unixtime

Item Description
Syntax unixtime(year, month, day, hour, min, sec)
Description Converts the specified date and time to a UNIX timestamp.
Note The UNIX timestamp is independent of time zones and represents the number of seconds elapsed since 00:00:00 (UTC) on January 1, 1970.
Parameters
  • year: the year.
  • month: the month.
  • day: the day.
  • hour: the hour.
  • min: the minute.
  • sec: the second.
Return value Returns a UNIX timestamp.
Examples
  • Example 1:
    t = unixtime(1970, 1, 1, 8, 0, 0)
    say(concat('unixtime()=', t))

    Output:

    unixtime()=0
  • Example 2:
    t = unixtime(2021,12,23,0,0,0)
    say(concat('unixtime()=', t))

    Output:

    unixtime()=1640188800