Timestamp SQL Guide

Learn how to work with timestamp SQL — getting the current Unix timestamp, converting timestamps to dates, and dates to timestamps in popular SQL databases.

Timestamp Converter

--
--
--
--
--

Convert seconds to human time

--
--

Current Timestamp in SQL

DatabaseCurrent Unix timestamp
MySQLSELECT UNIX_TIMESTAMP();
PostgreSQLSELECT EXTRACT(EPOCH FROM now());
SQLiteSELECT strftime('%s','now');
SQL ServerSELECT DATEDIFF(SECOND,'1970-01-01',GETUTCDATE());

Timestamp to Date in SQL

MySQL: SELECT FROM_UNIXTIME(1700000000);

PostgreSQL: SELECT to_timestamp(1700000000);

SQLite: SELECT datetime(1700000000,'unixepoch');

Date to Timestamp in SQL

MySQL: SELECT UNIX_TIMESTAMP('2023-11-14 22:13:20');

PostgreSQL: SELECT EXTRACT(EPOCH FROM TIMESTAMP '2023-11-14 22:13:20');

Home · Timestamp Python · Timestamp JavaScript