About
Tool No. 41 of Pikkola
A clock and a converter that answer one question two ways: what instant is this, and how do I write it so that another machine reads the same instant. Neither half keeps anything, and neither half talks to a server.
What it does
- A live clock counting the epoch in seconds, with the milliseconds, microseconds and nanoseconds below the second shown beside it, and a pause to read a value without chasing it.
- A converter in both directions: a timestamp in seconds, milliseconds, microseconds or nanoseconds, or a date and time, and the other side fills in as you type.
- Seven written forms of the same instant: ISO 8601 in UTC, ISO 8601 with the offset of a chosen zone, RFC 2822, a plain UTC string, the local reading of this device, the reading in any IANA time zone, and a relative phrase such as 3 hours ago.
- Offset arithmetic: +7d, -3h, +90m, start of month, end of day, and sums of those, applied in the chosen zone.
- A batch pass over a pasted list, one value per line, with a table, CSV copy and download, and JSON copy and download.
- Snippets for JavaScript, Python, Go, Rust, PostgreSQL, MySQL and Bash, written with the instant on the Convert tab.
The epoch, and what it leaves out
Unix time counts the seconds since 1970-01-01T00:00:00 UTC. The start is the UNIX epoch, and the count is the one POSIX defines: every day is 86,400 seconds, and a leap second is absorbed by the system clock instead of being added to the number. Two leap seconds have been inserted since 1972 and neither appears in a timestamp, which is why a conversion never needs a table of them and never disagrees with the value a server wrote into a log.
The count is unsigned in the common reading, and 32 bit machines once held it in a signed integer, which runs out on 2038-01-19T03:14:08Z. A 64 bit value does not run out in any year worth planning for. The third sample chip on the Convert tab is that edge, so the number can be seen rather than imagined.
Precision, from seconds to nanoseconds
A bare number is read by counting its digits: up to eleven is seconds, twelve to fourteen milliseconds, fifteen to seventeen microseconds, eighteen and above nanoseconds. The cut is not magic, it is what people paste, and the unit the page picked is written above the result so it can be overridden with the selector.
The instant is carried as a whole number of nanoseconds, held in a BigInt, so a nineteen digit value keeps its last digit instead of drifting in a floating point number. The written forms keep the fraction when there is one: a value ending in .412907631 is written with all nine digits in ISO 8601, and the seconds row keeps the fraction too, so a copy does not quietly lose the part below the second.
The last six digits of the live clock come from the browser's high resolution clock, which is precise to a fraction of a microsecond but is not a time server. It is right for measuring and for display; it is not evidence of what a remote machine will think the time is.
Zones, offsets and the wall clock
A timestamp is an instant and has no zone. A date on a screen is a wall clock and has no instant until a zone is named. This page keeps the two apart: the UTC lines never move with the selector, and the lines that do move say which zone they are in.
Zone rules come from the browser's own copy of the IANA database, through the Intl API, so summer time, historical offsets and the odd half hour zone are read from data rather than from a table on this page. When a zone skips an hour at the start of summer time, a wall clock time inside that hour does not exist, and the reading settles on the first moment after the gap. When a zone repeats an hour at the end of summer time, the earlier of the two is used.
A date typed with no offset is read in this device's zone, and the note under the field says so. That is a convenience, not a definition: the same text is two different instants in two zones, which is why an API asks for Z or an offset.
Offset arithmetic
Days, hours, minutes, seconds and milliseconds are fixed lengths: +1d is 24 hours, not one calendar day. Months and years follow the calendar in the chosen zone, and a day that does not exist in the target month is clamped to the last day of that month, so 31 January plus one month is 28 or 29 February.
An anchor such as start of month is applied first, then the terms are added in the order they were written. The result is normalised through a calendar so 25:00 becomes 01:00 the next day, and the wall clock is settled back into the zone afterwards.
What it deliberately does not do
- It does not check the clock against a server. The value is whatever this device believes, read at the moment the frame was painted.
- It does not parse every date in the world. A bare number and the common written forms are read; a phrase like next Tuesday at noon is not.
- It does not convert between calendars. The Gregorian calendar is the only one here, proleptic before 1582.
- It does not store anything on a server. The tab, the zone and the last values you typed are kept in this browser so the page opens where you left it.
- No account, no upload, no analytics, no cookies, no fonts or scripts from another server.
Why it is free
Pikkola builds small tools that do one job and keeps them free, with no account and no advertising. A static page that does its arithmetic in the browser costs almost nothing to serve, so there is no reason to charge for it.
Contact
A timestamp that reads wrong, a phrase that reads badly in Korean or Japanese, a zone that should be in the common list and is not: hello@pikkola.com. Send the value, the zone and what you expected to see.