A practical guide to epoch time: how to tell seconds from milliseconds, why you should store UTC, how DST bites, and what the year 2038 problem means.
A Unix timestamp counts the seconds elapsed since 00:00:00 UTC on 1 January 1970, ignoring leap seconds. Because it is a single number in UTC, it has no time zone and no daylight-saving ambiguity, which is why databases, logs, JWTs and APIs use it to record moments in time.
The number itself is always UTC. Time zones only appear when you convert it to a human-readable date for display. Keeping that separation clear (store the instant, format at the edge) prevents most date bugs.
Unix tools, PHP, Python's time.time() integer part, PostgreSQL's extract(epoch) and JWT claims use seconds. JavaScript's Date.now(), Java's System.currentTimeMillis() and many JSON APIs use milliseconds. Mixing them up is the single most common timestamp bug.
The quick test is digit count. A current timestamp in seconds has 10 digits (around 1.8 billion in late 2026). In milliseconds it has 13 digits. Microseconds have 16 and nanoseconds 19. If a date renders as January 1970, you probably treated seconds as milliseconds; if it renders tens of thousands of years in the future, you treated milliseconds as seconds.
Store instants as UTC timestamps or as ISO 8601 strings with an explicit offset (for example 2026-11-16T09:30:00Z). Convert to the user's time zone only when rendering. Storing local wall-clock times without a zone makes it impossible to order events correctly across regions.
There is one important exception: future events defined in local time, such as a meeting at 9:00 in New York next March. Time-zone rules change, so store the local time plus the IANA zone name (America/New_York) and compute the instant when you need it.
Adding 24 hours to a timestamp is not the same as adding one calendar day. On a DST transition day, a local day is 23 or 25 hours long, so "tomorrow at the same time" computed with raw seconds lands an hour off. Use a date library's calendar arithmetic for day, month and year math.
Some local times do not exist (the hour skipped when clocks spring forward) and some occur twice (the hour repeated when they fall back). Code that parses local times without handling these cases will produce off-by-one-hour errors twice a year, and regions occasionally change or abolish DST with little notice.
Systems that store Unix time in a signed 32-bit integer can count up to 2,147,483,647 seconds, which is 03:14:07 UTC on 19 January 2038. One second later the value overflows to a large negative number and dates jump back to 1901.
Modern 64-bit operating systems and languages are not affected, but old embedded devices, file formats, database columns typed as INT and legacy C code still are. If you design a schema today, use a 64-bit integer (BIGINT) or a native timestamp type, especially for values that may already reach past 2038, such as 15-year certificates or long-term loan schedules.
Current time in seconds: date +%s (shell), Math.floor(Date.now() / 1000) (JavaScript), int(time.time()) (Python). Convert seconds to a date: date -d @1700000000 (GNU) or date -r 1700000000 (macOS), new Date(1700000000 * 1000) (JavaScript), datetime.fromtimestamp(1700000000, tz=timezone.utc) (Python).
When in doubt, paste the number into a converter that shows both the UTC and local interpretation side by side, and check whether the seconds or the milliseconds reading gives a plausible date.