A Unix timestamp counts time since 1970-01-01 00:00:00 UTC. The count is simple, but the unit is not written down: the same instant is 1700000000 in seconds, 1700000000000 in milliseconds and 1700000000000000000 in nanoseconds. Most timestamp bugs come from reading one unit as another, or from formatting the right instant in the wrong zone.
How it works#
Type a number, an ISO 8601 date, or now.
- A number has its unit chosen from the count of digits before the decimal point: up to 11 digits is seconds, 12 to 14 is milliseconds, 15 to 17 is microseconds and 18 or more is nanoseconds. The verdict says which unit it chose and why, and the unit selector overrides it. Decimals are kept, so a float such as
1234567890.123456works. Underscores and thousands commas are ignored. - An ISO 8601 date with
Zor an offset such as+05:30is exact. Without an offset it is read as wall-clock time in the selected zone. If that time falls in a daylight-saving gap, the tool says it does not exist. If it happens twice, the tool shows the first occurrence and says so. nowstarts a live clock that updates every second and pauses while the tab is hidden. “Stop at this second” turns it into a fixed value you can share.
The instant is stored as a whole number of nanoseconds (a JavaScript BigInt). A regular number has 53 bits of precision, so 1700000000123456789 would silently become 1700000000123456800. Time zones come from your browser’s Intl data, the same IANA database Rails reads through TZInfo. Nothing is sent anywhere.
The results are the value in all four units, ISO 8601 in UTC and in the chosen zone, the local time, RFC 2822, the HTTP date used in Date and Last-Modified headers, and a relative time such as “3 years ago”.
A worked example: a Sidekiq job payload#
Sidekiq 8.0 changed how job timestamps are stored. In 7.x, created_at and enqueued_at are float seconds, such as 1234567890.123456. From 8.0 they are integer milliseconds, such as 1234567890123. The changelog gives the reason: floats lose precision in JSON and in JavaScript.
Paste either value. The first has 10 digits before the decimal point, so it is read as seconds: 2009-02-13T23:31:30.123456Z. The second has 13 digits, so it is read as milliseconds: 2009-02-13T23:31:30.123Z. If you compute queue latency by hand from a payload, now - enqueued_at needs the right unit for your Sidekiq version, or the answer is off by a factor of 1,000. Why background jobs are slow covers how latency is measured.
Ruby and Rails#
The snippet panel writes code that reproduces the exact instant, including the sub-second part:
t = Time.at(1700000000, 123, :millisecond).utc
t.iso8601(3) # => "2023-11-14T22:13:20.123Z"
t.to_i # => 1700000000
Time.at(1700000000, 123, :millisecond, in: "-05:00") # core Ruby: an offset
ActiveSupport::TimeZone["America/New_York"].at(1700000000, 123, :millisecond)
Some details matter here:
Time.at(seconds, subsec, unit)takes:millisecond,:usec(or:microsecond) and:nsec(or:nanosecond). Passing a 13-digit millisecond value as the only argument reads it as seconds:Time.at(1700000000000)is in the year 55840.in:takes a fixed offset, not a zone name.Time.at(x, in: "America/New_York")raisesArgumentError. Use ActiveSupport for named zones.Time.zone.atusesconfig.time_zone, andActiveSupport::TimeZone["…"].ataccepts any IANA name.iso8601,httpdateandrfc2822needrequire "time". Rails loads it for you; a plain Ruby script does not.- Rails stores
datetimecolumns in UTC. To read a raw database value, choose UTC or addZ.
Every commented result in the panel was checked by running it on Ruby 3.4 with ActiveSupport 8.1.
Limitations#
- The range is the JavaScript one: ±8.64e15 milliseconds around 1970. Ruby’s
Timegoes further. - Offsets before about 1970 depend on your browser’s time zone data, and browsers do not always agree. Old dates may show local mean time, such as New York’s −04:56:02 before 1883.
- Leap seconds do not exist in Unix time (see the FAQ).
- Relative time is rounded down to whole units, and a year is taken as 365.2425 days.
- ISO input covers calendar dates (
YYYY-MM-DD) with an optional time. Week dates (2026-W10), ordinal dates (2026-067) and durations are not parsed.
Frequently asked questions
How do I tell seconds from milliseconds?
Count the digits. A present-day timestamp has 10 digits in seconds, 13 in milliseconds, 16 in microseconds and 19 in nanoseconds. The tool reads 1 to 11 digits as seconds, 12 to 14 as milliseconds, 15 to 17 as microseconds and 18 or more as nanoseconds, and says which it chose. Pick a unit to override it.
Why does Time.at(x, in: "America/New_York") raise an error?
In core Ruby the in: keyword takes a fixed offset such as "-05:00", "UTC", a military letter or an integer number of seconds, not a zone name. For a named zone that follows daylight saving, use ActiveSupport: Time.zone.at(x) or ActiveSupport::TimeZone["America/New_York"].at(x).
Can a Unix timestamp be negative?
Yes. A negative value counts back from 1970-01-01 00:00:00 UTC, so -1 is 23:59:59 on 31 December 1969. JavaScript dates reach 8.64e15 milliseconds either side of 1970, about 271,821 BC to 275,760 AD; the tool rejects anything outside that range with a message.
Do leap seconds change the result?
No. Unix time counts every day as exactly 86,400 seconds, so a leap second such as 23:59:60 has no timestamp of its own. The tool rejects :60 in an ISO date and explains why.
Is what I enter sent anywhere?
No. Parsing, time zone conversion and the Ruby snippets are computed in your browser with the built-in Intl time zone data. The page makes no network requests with your input.