Datetime to Unix Timestamp Converter
Converting a datetime to a Unix timestamp is the reverse of the standard epoch-to-date operation. You start with a human-readable date and time — either entered in fields or as a string — and get back the Unix integer that represents that exact moment. This is essential for database queries, API requests that require Unix timestamps, JWT token generation, and time arithmetic in code.
The date fields in section 2 of this page accept year, month, day, hour, minute, and second with a timezone selector. The string parser below it accepts almost any date format — ISO 8601, RFC 2822, and common locale-specific formats. The result is always a Unix timestamp in both seconds (10-digit) and milliseconds (13-digit).
Datetime to Unix timestamp: timezone is critical
The timezone you specify dramatically affects the resulting timestamp. "April 17, 2026 at noon" in UTC gives a different integer than "April 17, 2026 at noon" in New York (UTC-4) or Oslo (UTC+2). When converting a datetime to a Unix timestamp, always be explicit about which timezone the datetime is expressed in. If you're unsure, UTC is the safest choice for storage.
Code examples
JavaScript:
Math.floor(new Date('2026-04-17T10:35:00Z').getTime() / 1000)
Python (UTC aware):
from datetime import datetime, timezone
int(datetime(2026, 4, 17, 10, 35, 0, tzinfo=timezone.utc).timestamp())
MySQL:
SELECT UNIX_TIMESTAMP('2026-04-17 10:35:00');
PostgreSQL:
SELECT EXTRACT(EPOCH FROM TIMESTAMPTZ '2026-04-17 10:35:00 UTC')::INT;