Description
The toTimestamp
function returns the UNIX timestamp (number of milliseconds since January 1, 1970, 00:00:00 UTC) for the specified date.
Syntax
toTimestamp(date)
Arguments
Argument | Description |
---|---|
date |
The date for which the UNIX timestamp should be calculated. The format should be YYYY-MM-DD . |
Return Value
The function returns a numeric UNIX timestamp in milliseconds that corresponds to the specified date.
Examples
Description | Example |
---|---|
Converting a date to a timestamp |
toTimestamp("2023-01-01")Result: 1672531200000 |
Converting the current date to a UNIX timestamp |
toTimestamp(now())Result: (corresponds to the current timestamp in milliseconds) |
Notes
- If the given date is invalid, the function may produce an error or return no result.
- This function uses UTC as its time zone.
- Note that the return value is in milliseconds. To obtain the timestamp in seconds, divide the result by
1000
.
Comments
0 comments
Please sign in to leave a comment.