Unix timestamp converter
Convert Unix timestamps to dates and back, in any time zone, with ISO 8601, RFC 2822 and relative time.
Code examples
Copy and paste these into your own project. Each one uses only the language's standard library, so there is nothing to install.
const now = Math.floor(Date.now() / 1000)
console.log(now)What it does
Convert Unix timestamps to readable dates and dates back to timestamps, in any time zone. It understands seconds, milliseconds, microseconds and nanoseconds, and writes ISO 8601, RFC 2822 or plain Unix time.
How to use it
- Type or paste a Unix timestamp or a date: ISO 8601, RFC 2822, an HTTP date,
2023-11-14 22:13or14-11-2023. Now inserts the current time. - Leave the unit on Detect unit, or choose seconds, milliseconds, microseconds or nanoseconds.
- Pick the time zone to read dates without an offset in, and the format to write.
- Read every format of that moment in the rows below and edit any of them: the others follow. The start and end of its day, month and year, and how far it is from now, are listed too.
- Use Several lines to convert one value per line, and the duration box to turn seconds into years, days, hours, minutes and seconds.
Examples
1700000000 → 2023-11-14T22:13:20.000Z
1700000000123 → 2023-11-14T22:13:20.123Z
2023-11-14 23:13 → 1699999980 (read in Europe/Amsterdam, UTC+1)
Good to know
- A timestamp names one exact moment. The time zone only changes how it is written.
- Up to 10 digits are read as seconds, 13 as milliseconds, 16 as microseconds and 19 as nanoseconds.
- A date with no offset is read as local time in the zone you chose; add
Zor+01:00to be explicit. - Dates run from year 0000 to 9999.
03-04-2023could be 3 April or 4 March. Date order decides how it is read: day first or month first.- The live clock shows the current time in seconds, milliseconds, microseconds and nanoseconds. Your browser only gives milliseconds, so the last two end in zeros. Pause it to copy a value.
The current time in code
JavaScript Math.floor(Date.now() / 1000)
Python int(time.time())
Go time.Now().Unix()
PHP time()
SQL SELECT EXTRACT(EPOCH FROM NOW())::bigint; -- PostgreSQL
Bash date +%s
What is a Unix timestamp?
A Unix timestamp counts the time since 1 January 1970 00:00:00 UTC, the Unix epoch. It is usually written in seconds, but many systems use milliseconds (JavaScript, Java), microseconds or nanoseconds. A timestamp always names one exact moment, whatever the time zone.
Frequently asked questions
How does the tool know if a number is in seconds or milliseconds?
By its size: up to 10 digits is read as seconds, 13 digits as milliseconds, 16 as microseconds and 19 as nanoseconds. Pick a unit yourself if your values are unusual.
What happens with a date that has no time zone?
It is read as a wall-clock time in the time zone you chose, UTC by default. Add Z or an offset such as +01:00 to the date and that is used instead.
Does this tool send my timestamps anywhere?
No. Everything is calculated on your device with your browser's built-in date support. What you type is never sent to our servers.