to_timestamp

Converts UINT256 seconds since the Unix epoch to a timezone-naive TIMESTAMP. Interpret the result as UTC when the source value is an EVM block timestamp.

Scalar function TypesEVM

Example

Runs locally

-- Interpret an EVM block timestamp as UTC
SELECT to_timestamp(1700000000::UINT256)::VARCHAR AS block_time;
-- => [{"block_time":"2023-11-14 22:13:20"}]

API reference

to_timestamp(UINT256) #

Converts unsigned Unix seconds to TIMESTAMP. Values above INT64_MAX return NULL; values within INT64 that exceed the supported TIMESTAMP conversion range can raise a Conversion Error.

Inputs

Name Type Use
unix_seconds UINT256

UINT256 whole seconds since 1970-01-01 00:00:00. NULL returns NULL.

required positional

Returns

Name Type
timestamp TIMESTAMP

SQL timestamp. Returns a timezone-naive TIMESTAMP. Values above INT64_MAX return NULL; other out-of-range conversions may throw.

Examples

Runs locally

-- A large timestamp that still converts successfully
SELECT to_timestamp(253402300799::UINT256)::VARCHAR AS upper_example;
-- => [{"upper_example":"9999-12-31 23:59:59"}]