Date to Epoch: Convert Time to Unix Timestamp or Epoch Time
Learn how to convert a human date and time to epoch time, Unix timestamp seconds, Unix timestamp milliseconds, or ISO output. Covers timezone selection, UTC conversion, API payloads, and common mistakes.
What date to epoch conversion means
Date to epoch conversion takes a human-readable date, clock time, and timezone, then returns a numeric timestamp. The numeric result represents one instant everywhere. For example, 2026-01-01 00:00:00 UTC converts to Unix seconds 1767225600.
Timezone is part of the input
A local time like 2026-01-01 00:00 is incomplete without a timezone. Midnight in UTC, New York, Los Angeles, London, and Tokyo are different instants and therefore different epoch timestamps. Always choose the timezone before converting time to Unix timestamp.
- 2026-01-01 00:00 UTC = 1767225600 seconds
- 2026-01-01 00:00 America/New_York = 1767243600 seconds
- 2026-01-01 00:00 America/Los_Angeles = 1767254400 seconds
- 2026-01-01 00:00 Asia/Tokyo = 1767193200 seconds
Seconds or milliseconds?
After converting a date to epoch, choose the unit required by the target system. Backend APIs, Linux commands, PHP, Python, Go, and many SQL functions commonly use Unix seconds. JavaScript Date, browser APIs, and many analytics payloads commonly use Unix milliseconds.
- Unix seconds: 1767225600
- Unix milliseconds: 1767225600000
- JavaScript: new Date('2026-01-01T00:00:00Z').getTime() returns milliseconds
- JavaScript seconds: Math.floor(new Date('2026-01-01T00:00:00Z').getTime() / 1000)
- SQL often accepts seconds through to_timestamp() or FROM_UNIXTIME()
Where date to epoch is used
Date to epoch conversion is useful whenever a system wants a numeric time boundary instead of a formatted date string.
- API tests that need expires_at or starts_at values
- Database migrations that backfill timestamp columns
- Analytics queries that need start and end epoch boundaries
- Cron, scheduling, and queue jobs that store run times numerically
- Signed URLs and tokens with expiration timestamps
Date to epoch FAQ
- How do I convert time to epoch time?
- Choose the date, clock time, and timezone, then convert that instant to Unix seconds or milliseconds. If the timezone is missing, the result may be off by hours.
- Is timestamp to epoch the same as date to epoch?
- Usually yes. It means converting a readable timestamp or date-time string into an epoch number.
- Should I send epoch seconds or milliseconds to an API?
- Follow the API documentation. If it says Unix timestamp, it often means seconds, but JavaScript-oriented APIs may expect milliseconds.
- Why does the same date give a different epoch in different timezones?
- Because a local wall-clock time only identifies an instant once a timezone is attached. 2026-01-01 00:00 is 1767225600 in UTC but 1767243600 in New York — five hours later in real time. Set the timezone before converting.