All Products
Search
Document Center

Realtime Compute for Apache Flink:UNIX_TIMESTAMP

Last Updated:Mar 26, 2026

Converts a date or timestamp value into a UNIX timestamp (BIGINT).

Limitations

This function is supported only in Realtime Compute for Apache Flink that uses Ververica Runtime (VVR) 3.0.0 or later.

Syntax

BIGINT UNIX_TIMESTAMP(VARCHAR date)
BIGINT UNIX_TIMESTAMP(TIMESTAMP timestamp)
BIGINT UNIX_TIMESTAMP(VARCHAR date, VARCHAR format)

Input parameters

ParameterData typeDescription
dateVARCHARA date string to convert. Default format: yyyy-MM-dd HH:mm:ss.
timestampTIMESTAMPA TIMESTAMP value to convert.
formatVARCHARThe format pattern for parsing date. Default: yyyy-MM-dd hh:mm:ss.

Examples

Basic conversion

Test data (table T1)

date1 (VARCHAR)date2 (VARCHAR)
2021-03-25 00:00:001970-01-01 00:00:00

Test statement

SELECT UNIX_TIMESTAMP(TO_TIMESTAMP_TZ(date1, 'Asia/Shanghai')) AS big1,
       UNIX_TIMESTAMP(date2) AS big2
FROM T1;

Test result

big1 (BIGINT)big2 (BIGINT)
1616601600-28800