Reading timestamps in logs and APIs
Logs, databases, JWT expiry fields and API responses store time as the number of seconds (or milliseconds) since 1 January 1970 UTC. Paste one to see the date it means in UTC and in your time zone; the unit is detected from the number of digits, so 1730000000 and 1730000000000 both come out right.
Time zones and the 2038 limit
A timestamp has no time zone: it is the same instant everywhere, only its display changes. Pick any zone to see the local time, daylight saving included, and copy the ISO 8601 form for code. Systems that store timestamps as signed 32-bit integers stop on 19 January 2038 at 03:14:07 UTC; 64-bit storage has no such limit.
Timestamps in APIs
REST APIs commonly use Unix timestamps instead of formatted date strings because they are timezone-agnostic, unambiguous, compact, and easy to compare mathematically. A timestamp like 1742045400 means exactly the same thing regardless of where the server or client is located.
Some APIs use seconds (Unix standard), others use milliseconds (JavaScript standard). Always check the API documentation. A quick way to tell: 10 digits = seconds, 13 digits = milliseconds.
Timezones and UTC: the source of bugs
Timezone-related bugs are among the most common in software development. A timestamp stored in UTC is absolute, but displaying it in a user's local timezone requires knowing their offset — which changes with daylight saving time.
Best practice: always store timestamps in UTC (or as Unix timestamps), and only convert to local time for display. Never store local times without timezone information.
Code examples
Getting the current timestamp: JavaScript — Date.now() returns milliseconds, use Math.floor(Date.now()/1000) for seconds. Python — time.time() returns a float in seconds. PHP — time() returns seconds. Java — System.currentTimeMillis() returns milliseconds.
Converting a timestamp to a date: JavaScript — new Date(timestamp * 1000). Python — datetime.fromtimestamp(timestamp). PHP — date('Y-m-d H:i:s', timestamp). SQL — FROM_UNIXTIME(timestamp) in MySQL, to_timestamp(timestamp) in PostgreSQL.