Datetime to Unix Timestamp Converter

Current Unix Time
Advertisement

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;

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!