Date to Epoch Converter

Need to store a date as a single integer? Convert to epoch time (seconds since 1970-01-01 UTC). The result is timezone-agnostic and sorts correctly.

Example: 2024-01-31T12:00:00Z

Input (Date)2024-01-31T12:00:00Z
Unix (seconds)1706702400
Unix (milliseconds)1706702400000
ISO 8601 (UTC)2024-01-31T12:00:00Z

Common Pitfall

Note: Dates before 1970 produce negative epoch values. Most modern systems handle this fine, but some legacy code (and 32-bit signed-integer storage) breaks below `-2147483648` (Dec 13, 1901).

Code Examples

Python

from datetime import datetime, timezone
int(datetime(2024, 1, 31, 12, 0, tzinfo=timezone.utc).timestamp())

JavaScript

Math.floor(new Date('2024-01-31T12:00:00Z').getTime() / 1000)

PHP

strtotime('2024-01-31 12:00:00 UTC');

Bash

date -u -d "2024-01-31 12:00:00" +%s   # GNU date

Related Conversions

Need the full converter? Open the Timestamp Converter →