Unix timestamp guide | UnixDate

Developer guide for working with Unix timestamps safely and predictably.

SQL epoch conversions

Different databases handle epoch conversions differently, especially with timezones. Prefer explicit UTC conversions.

PostgreSQL

SELECT to_timestamp(1700000000) AT TIME ZONE 'UTC';

MySQL

SELECT FROM_UNIXTIME(1700000000);

SQLite

SELECT datetime(1700000000, 'unixepoch');