What a Unix timestamp is
A Unix timestamp counts the seconds since 00:00:00 UTC on 1 January 1970, a moment called the Unix epoch. It is a single number with no time zone, which makes it easy to store, compare and send between systems.
Tokens, logs, databases and APIs use it everywhere. In JWTs, the claims exp, iat, nbf and auth_time are Unix seconds; RFC 7519 calls this a NumericDate. Reading them as dates is the first step in most token debugging.
Seconds, milliseconds and more
Not every system counts in seconds. JavaScript’s Date.now(), Java’s System.currentTimeMillis() and many APIs use milliseconds. Some logs and databases use microseconds or nanoseconds. The number of digits tells you which, for dates near the present.
| Unit | Digits for current dates | Example for 2025-11-24 16:00 UTC |
|---|---|---|
| Seconds | 10 | 1764000000 |
| Milliseconds | 13 | 1764000000000 |
| Microseconds | 16 | 1764000000000000 |
| Nanoseconds | 19 | 1764000000000000000 |
This converter detects the unit from the number of digits, and you can set it yourself when a value is ambiguous.
What this converter does
- Turns a timestamp into a date in UTC (ISO 8601 and RFC 7231 style), in your time zone, and relative to now.
- Gives the value in both seconds and milliseconds.
- Also accepts a date string such as
2026-11-25T10:00:00Zand turns it into a timestamp. - Turns a date and time you pick, in UTC or in your time zone, into seconds, milliseconds and ISO 8601.
- Shows the current time as Unix seconds, updated every second.
How to convert
- Paste a timestamp, for example an
expvalue from a token. - Check the “Read as” line to confirm the unit; change it if needed.
- Read the date in UTC and in your time zone.
- To go the other way, pick a date and time, say whether it is UTC, and copy the seconds.
How the conversion works
Converting seconds to a date is a multiplication and a call to the date library: the browser’s Date works in milliseconds, so seconds are multiplied by 1000. Converting back divides by 1000 and rounds down.
const exp = 1764000300;
new Date(exp * 1000).toISOString(); // "2025-11-24T16:05:00.000Z"
Math.floor(Date.now() / 1000); // current Unix secondsUnix time ignores leap seconds: every day is exactly 86,400 seconds. That keeps arithmetic simple and is why adding 3600 always means one hour later.
Timestamps in Keycloak
Keycloak uses both units, depending on where you look.
| Where | Unit |
|---|---|
Token claims: exp, iat, auth_time | Seconds |
Introspection responses: exp, iat | Seconds |
Admin REST API: a user’s createdTimestamp | Milliseconds |
Admin REST API: event time values | Milliseconds |
Mixing the two is a classic source of bugs: comparing a token’s exp with Date.now() without dividing makes every token look expired by decades, or valid forever, depending on the direction.
Logs are another common source. Keycloak’s own server log prints readable dates, but events and admin events fetched through the admin REST API carry their time in milliseconds. Paste such a value here to read it in your time zone.
Use cases
Reading a token’s expiry
Paste the exp value to see when a token stops working. For all of a token’s times on one timeline, use the expiry checker.
Writing a test token
Pick a date a few minutes ahead, copy the seconds, and use them as exp in the JWT encoder.
Reading logs and events
Paste a time from a Keycloak event or an application log to see when it happened in your own time zone.
Comparing times across systems
Convert values from two systems to UTC to check whether a “not yet valid” or “expired” error comes from a clock difference.
Common mistakes
- Using milliseconds in a JWT claim. Libraries expect seconds and will misread the value.
- Converting a timestamp “to a time zone”. A timestamp has no time zone; only its display does.
- Parsing a date string without a zone.
2026-11-25T10:00is read as local time in most environments; addZor an offset to be exact. - Assuming 32-bit storage is enough. Signed 32-bit seconds run out in January 2038.
Timestamps in different languages
Every platform can produce and read Unix time, but the default unit differs. These lines all produce seconds.
# shell
date +%s
date -u -d @1764000000 # GNU date: seconds to a UTC date
// JavaScript
Math.floor(Date.now() / 1000)
# Python
int(time.time())
// Java
Instant.now().getEpochSecond()On macOS, date -r 1764000000 converts seconds to a date, because the BSD date command does not support -d @.
Databases add their own conventions. PostgreSQL’s to_timestamp(1764000000) turns seconds into a timestamp with time zone, and extract(epoch from now()) goes the other way, with a fractional part. MySQL has FROM_UNIXTIME and UNIX_TIMESTAMP. When a column holds numbers, check whether they are seconds or milliseconds before converting.
Spreadsheets count days, not seconds, from their own epoch. To turn Unix seconds into a spreadsheet date, divide by 86,400 and add the spreadsheet’s value for 1 January 1970.
ISO 8601 and time zones
ISO 8601 is the readable companion to Unix time. A full value such as 2025-11-24T16:00:00Z names the date, the time and the zone. The Z means UTC; an offset such as +01:00 means one hour ahead of UTC.
2025-11-24T16:00:00Zand2025-11-24T17:00:00+01:00are the same moment.2025-11-24T16:00:00without a zone is ambiguous; most software reads it as local time.2025-11-24alone is usually read as midnight UTC in JavaScript, but as local midnight in other tools.
When you send times between systems, include the zone, or send Unix seconds. This converter’s date input lets you say whether the time you pick is UTC or local, so the result is never ambiguous.
Doing date arithmetic with timestamps
Because Unix time counts plain seconds, arithmetic is simple. That is one reason tokens use it.
| Span | Seconds |
|---|---|
| One minute | 60 |
| Five minutes, Keycloak’s default access token lifespan | 300 |
| One hour | 3,600 |
| One day | 86,400 |
| One week | 604,800 |
To build a token that expires in 10 minutes, take the current seconds and add 600. To find a token’s lifetime, subtract iat from exp. To check how long ago a user signed in, subtract auth_time from now.
Calendar arithmetic is different. Adding “one month” or “one day” across a daylight-saving change in a local time zone is not a fixed number of seconds; use a date library for that, and keep tokens in plain seconds.
Inside a JWT, the arithmetic is always done in seconds. A refresh that is due 30 seconds before expiry happens at exp - 30, whatever the user’s time zone or daylight-saving rules. That is exactly why token formats avoid calendar dates and local times.
When you write such values by hand, convert a date here once, then add the span from the table. It is less error-prone than converting every value separately.
Limits
The converter handles dates the browser’s Date can represent, more than 270,000 years either side of 1970. Values outside that range are refused. Detection by digit count assumes dates within a few centuries of now; for anything else, set the unit yourself.
The current time comes from your computer’s clock. If it is wrong, “relative” times are wrong too.
Best practices
- Store and send times as UTC timestamps or ISO 8601 with a zone; convert to local time only for display.
- Name fields by unit when you design an API, such as
createdAtMs, to avoid confusion. - Use 64-bit integers for timestamps.
- Keep server clocks synced with NTP so timestamps from different machines agree.