Vad Är en Unix-tidsstämpel? En Komplett Förklaring av Epoch-tid
Quick Answer
En Unix timestamp är antalet sekunder sedan 1 januari 1970, 00:00:00 UTC (Unix epoch). Den är timezone-oberoende och lätt att jämföra. JavaScript använder millisekunder (13 siffror); Unix och de flesta API:er använder sekunder (10 siffror). Använd vår gratis Timestamp Converter.
Introduction
En Unix timestamp (kallas även Unix epoch time, POSIX time eller Unix time) är antalet sekunder som förflutit sedan 1 januari 1970, 00:00:00 UTC —ett ögonblick känt som Unix epoch. Timestamps används ofta i operativsystem, databaser, loggar och API:er eftersom de är timezone-oberoende (alltid UTC), lätta att jämföra och kompakta. De är dock inte mänskligt-läsbara —1693526400 betyder ingenting utan konvertering.
Step by Step
-
Understand the Unix epoch
The Unix epoch is January 1, 1970, 00:00:00 Coordinated Universal Time (UTC). A Unix timestamp is the count of seconds from this moment. Positive timestamps are after the epoch; negative timestamps (supported by some systems) are before it.
-
Distinguish seconds from milliseconds
Unix timestamps are typically in seconds (10 digits as of 2026, e.g., 1693526400). JavaScript's Date.now() and Date.getTime() return milliseconds (13 digits, e.g., 1693526400000). Always check which unit an API expects — mixing them is the most common timestamp bug.
-
Understand timezone independence
Unix timestamps are always UTC. They do not depend on the user's timezone. To display a timestamp in a specific timezone, convert it to a date and apply the timezone offset. This makes timestamps ideal for storage and comparison.
-
Learn about the Year 2038 problem
Systems using 32-bit signed integers for timestamps will overflow on January 19, 2038, 03:14:07 UTC — the 'Y2038 problem'. Systems using 64-bit integers or JavaScript numbers (64-bit floats) are unaffected. Modern systems are largely Y2038-safe, but legacy embedded systems may not be.
Examples
Timestamp for a known date
Input: 2023-09-01 00:00:00 UTC
Output: 1693526400 (seconds) or 1693526400000 (milliseconds)
The Unix epoch
Input: 1970-01-01 00:00:00 UTC
Output: 0
Y2038 problem boundary
Input: 2038-01-19 03:14:07 UTC
Output: 2147483647 (max 32-bit signed integer)
Common Problems
- Mixing seconds and milliseconds —JavaScript uses milliseconds (Date.now()), Unix and most APIs use seconds. Divide by 1000 to convert ms to seconds; multiply by 1000 for the reverse.
- Timezone confusion —timestamps are UTC. When displaying, convert to the user's local timezone or specify UTC. Do not apply offsets to the raw timestamp.
- The Year 2038 problem —32-bit signed integer timestamps overflow on 2038-01-19. Use 64-bit integers or JavaScript numbers to avoid this.
- Negative timestamps —dates before 1970-01-01 have negative timestamps. Some systems do not support them.
Tips
- Always check whether an API expects seconds or milliseconds —this is the most common timestamp bug.
- Use ISO 8601 strings (e.g., "2023-09-01T00:00:00Z") for human-readable timestamps in APIs; use Unix epoch for storage and computation.
- JavaScript Date.now() returns milliseconds; divide by 1000 and floor to get seconds.
- Use our Timestamp Converter to convert between timestamps and human-readable dates in your browser.