TO_UNIX_TIMESTAMP_US
Description
The TO_UNIX_TIMESTAMP_US
function is used to convert various types of time expressions into Unix timestamps (microseconds), which is the total number of microseconds from January 1, 1970, 00:00:00 UTC to the specified time.
Parameter Description
expr
: Timestamp expression, which can be a string, timestamp, etc.
Return Type
The return type is BIGINT
.
Usage Example
- Convert from string to Unix timestamp (microseconds):
- Get Unix timestamp (microseconds) from the current time:
- Convert from timestamp to Unix timestamp (microseconds):
- Convert the current timestamp to Unix timestamp (microseconds) and add an offset:
Notes
- Please ensure that the input time expression format is correct, otherwise it may cause conversion failure.
- The Unix timestamp (microseconds) returned by this function can be used for calculating time differences, operations between timestamps, etc.