Epoch & Unix Timestamp in MySQL

Get the current epoch timestamp

SELECT UNIX_TIMESTAMP();

Convert epoch to date

SELECT FROM_UNIXTIME(1718200000);

Convert date to epoch

SELECT UNIX_TIMESTAMP('2026-06-12 00:00:00');

MySQL notes

FROM_UNIXTIME returns the value in the session time_zone — set time_zone = '+00:00' for UTC. TIMESTAMP columns are stored as UTC but displayed per session zone.

Check any value live with the epoch converter, or read what Unix time actually counts.

Other languages

C · C# · C++ · Dart · Go · Java · JavaScript · Kotlin · Perl · PHP · PostgreSQL · Python · R · Ruby · Rust · Scala · SQLite · Swift · TypeScript