Updated on 2026-11-06 GMT+08:00

to_utc_timestamp

The to_utc_timestamp function is used to convert a timestamp corresponding to the specified timezone to a UTC timestamp.

Syntax

to_utc_timestamp(string timestamp, string timezone)

Parameters

Table 1 Parameter descriptions

Parameter

Mandatory

Type

Description

timestamp

Yes

DATE, TIMESTAMP, or STRING

The timestamp to be converted

Formats:

yyyy-MM-dd

yyyy-MM-dd HH:mm:ss

yyyy-MM-dd HH:mm:ss.SSS

timezone

Yes

STRING

The target time zone for conversion.

Return Values

Returns a value of type BIGINT.

  • If timestamp is not of type DATE or STRING, an error is returned with the message "data type mismatch".
  • If timestamp is of type DATE or STRING but does not conform to the input format for date values, NULL is returned.
  • If the timestamp value is NULL, NULL is returned.
  • If the timezone value is NULL, NULL is returned.

Example Code

Returns 1692028800000.

select to_utc_timestamp('2023-08-14 17:00:00','PST');

Returns NULL.

select to_utc_timestamp(null, 'PST');