This topic describes the syntax, features, parameters, and return values of time functions. This topic also provides examples of these functions.
today | time | now | localtime | utctime | cookie_time | http_time | parse_http_time | unixtime
today
Item | Description |
---|---|
Syntax | today()
|
Feature | Returns the current date in the format of yyyy-mm-dd. |
Parameter | N/A |
Return value | The current date in the format of yyyy-mm-dd. Data type: string. |
Example | Output:
|
time
Item | Description |
---|---|
Syntax | time()
|
Feature | Queries the current UNIX timestamp, excluding the fractional part of milliseconds. Unit: seconds. |
Parameter | N/A |
Return value | The current UNIX timestamp. |
Example | Output:
|
now
Item | Description |
---|---|
Syntax | now()
|
Feature | Queries the current UNIX timestamp, including the fractional part of milliseconds. Unit: seconds. |
Parameter | N/A |
Return value | The current UNIX timestamp. |
Example | Output:
|
localtime
Item | Description |
---|---|
Syntax | localtime()
|
Feature | Returns the current date and time in the format of yyyy-mm-dd hh:mm:ss. |
Parameter | N/A |
Return value | The current date and time in the format of yyyy-mm-dd hh:mm:ss. Data type: string. |
Example | Output:
|
utctime
Item | Description |
---|---|
Syntax | utctime()
|
Feature | Queries the current UTC time in the format of yyyy-mm-dd hh:mm:ss. |
Parameter | N/A |
Return value | The current date and time in the format of yyyy-mm-dd hh:mm:ss. Data type: string. |
Example | Output:
|
cookie_time
Item | Description |
---|---|
Syntax | cookie_time(sec)
|
Feature | Generates a time string that can be used in cookies based on a UNIX timestamp. |
Parameter | sec: a UNIX timestamp. To query the UNIX timestamp, you can call the time() function.
|
Return value | A time string that indicates the expiration time of the cookie based on the UNIX timestamp
specified by the sec parameter.
|
Example | Output:
|
http_time
Item | Description |
---|---|
Syntax | http_time(sec)
|
Feature | Generates a time string that can be used in HTTP headers based on a UNIX timestamp. For example, a time string that can be used in the Last-Modified header. |
Parameter | sec: a UNIX timestamp. To query the UNIX timestamp, you can call the time() function.
|
Return value | A time string that can be used in HTTP headers based on the UNIX timestamp specified
by the sec parameter.
|
Example | Output
|
parse_http_time
Item | Description |
---|---|
Syntax | parse_http_time(str)
|
Feature | Parses a time string that can be used in HTTP headers and returns the corresponding UNIX timestamp. |
Parameter | str: the time string that you want to parse. Example: Thu, 22-Dec-10 10:20:35 GMT . To query the time string, you can call the http_time() function.
|
Return value | If the function succeeds, a UNIX timestamp is returned. Otherwise, false is returned.
|
Example | Output
|
unixtime
Item | Description |
---|---|
Syntax | unixtime(year, month, day, hour, min, sec)
|
Feature | Generates and returns a UNIX timestamp based on the provided values of the year, month, day, hour, min, and sec parameters. |
Parameter |
|
Return value | A UNIX timestamp. |
Example | Output
|