Web Toolkit

Date & Time tools

Timestamps, timezones and date arithmetic that actually handles edge cases.

Dates are where confident code breaks. A Unix timestamp in a log is seconds, the one in your JavaScript is milliseconds, and reading one as the other puts you in 1970 or the year 56000. Counting days between two dates by hand fails at month boundaries, leap years and the two days a year when daylight saving time makes a "day" 23 or 25 hours long.

Use the timestamp converter when you are reading logs, debugging an expiry claim or checking what a database actually stored — it shows the value in your local timezone and in UTC at the same time, which is usually where the confusion was. Use the date difference calculator for contract terms, notice periods, age calculations and anything where being one day out has consequences.

Seconds, milliseconds and the year-56000 test

You can usually tell which unit a timestamp is in by its length. Ten digits is seconds and will be in the current decade; thirteen digits is milliseconds. If a converter tells you an event happened in January 1970, the value was milliseconds read as seconds and has been divided by a thousand. If it lands tens of thousands of years in the future, the opposite happened. The converter here accepts either and labels which one it assumed, so the first thing to check when a date looks absurd is that label, not the source system.

The second thing to check is the timezone. A timestamp itself has no timezone — it is a count of seconds since midnight UTC on 1 January 1970 — but every human-readable rendering of it does. "2024-03-10 02:30" is a different instant in Tokyo, London and New York, and in New York on that particular night it does not exist at all, because the clocks skipped from 01:59 to 03:00. When two systems disagree about a date by exactly one, eight or nine hours, the bug is almost never in the arithmetic.

Why counting days is harder than it looks

The date difference calculator answers a question that sounds trivial and is not: how many days between two dates? The honest answer depends on whether you count the start day, the end day, both or neither — a "30-day notice period" starting on the 1st ends on the 31st under one convention and the 30th under another, and contracts have been argued over less. The calculator shows the count both ways and states which convention each number follows, so you can match it to the wording you are actually bound by.

Months and years are worse, because they are not fixed lengths. The gap from 31 January to 28 February is one month by most people's intuition and 28 days by arithmetic; add a day and it is either "one month and one day" or "still one month", depending on the rule. The calculator reports a whole-unit breakdown (years, months, days) alongside the total day count precisely so that when the two seem to disagree, you can see why rather than trusting whichever you noticed first.

What runs where

The timestamp converter uses your browser's own timezone database and the JavaScript Date API, so the local rendering matches the machine you are sitting at rather than a server in another region. That is the right behaviour for debugging — you want to see what your users would see — but it also means a result from a laptop in Berlin will differ from a colleague's in Singapore by design. When you share a converted date with someone else, share the UTC rendering or the raw timestamp, never the local one.

The date difference calculator does the opposite on purpose: it reads both dates as midnight UTC and counts from there, so a daylight-saving change in your own timezone can never make a span come out a day short. Business days are counted Monday to Friday with no knowledge of public holidays, because holidays depend on a country the page does not know.

Guides

Other categories