MySQL Timestamp Converter

Current Unix Time
Advertisement

MySQL Timestamp Converter

MySQL provides native functions for working with Unix timestamps: UNIX_TIMESTAMP() converts a datetime value to a Unix integer, and FROM_UNIXTIME() converts a Unix integer back to a datetime string. These functions are the foundation of time-based querying in MySQL and are used extensively in applications that store timestamps as integers for performance.

MySQL also has a TIMESTAMP column type, which stores datetime values internally as UTC and automatically converts to/from the server's timezone on read/write. This is different from storing an INTEGER Unix timestamp, which is timezone-neutral. The TIMESTAMP column type has a range limitation (1970–2038) due to its 32-bit storage, while DATETIME or INTEGER columns can store values outside this range.

MySQL timestamp functions

Current Unix timestamp:
SELECT UNIX_TIMESTAMP();

Specific datetime to Unix:
SELECT UNIX_TIMESTAMP('2026-04-17 10:35:00');

Unix to datetime:
SELECT FROM_UNIXTIME(1700000000);
'2023-11-14 22:13:20'

Unix to formatted date:
SELECT FROM_UNIXTIME(1700000000, '%Y-%m-%d');

Filter by date range using Unix timestamps (fastest):
SELECT * FROM logs WHERE ts BETWEEN UNIX_TIMESTAMP('2026-01-01') AND UNIX_TIMESTAMP('2026-02-01');

Records from the last 24 hours:
SELECT * FROM events WHERE ts > UNIX_TIMESTAMP() - 86400;

Advertisement
// Epoch → Human-readable date

Auto-detects seconds (10 digits), milliseconds (13), microseconds (16), nanoseconds (19)

Invalid timestamp. Please enter a numeric Unix timestamp.
// Date → Epoch timestamp
Please check the values — year (1970–9999), month (1–12), day (1–31), hour (0–23), min/sec (0–59).

Or paste a date string:

Could not parse that date string.
Advertisement

← Back to all tools

Copied!