How to Convert Between Time Formats
Time formats vary across systems, APIs, and countries. Unix timestamps in API responses, ISO 8601 in databases, 12-hour clocks in the US, 24-hour clocks in Europe — converting between them is a constant need for developers and anyone working with international data.
Common time formats
| Format | Example | Used by |
|---|---|---|
| Unix timestamp (seconds) | 1712502600 | APIs, databases, JWT tokens |
| Unix timestamp (ms) | 1712502600000 | JavaScript, Java |
| ISO 8601 | 2026-04-07T14:30:00Z | JSON APIs, databases, logs |
| RFC 2822 | Mon, 07 Apr 2026 14:30:00 +0000 | Email headers, HTTP |
| 24-hour | 14:30 | Europe, military, aviation |
| 12-hour | 2:30 PM | US, casual use |
Quick conversion reference
12-hour to 24-hour
| 12-hour | 24-hour |
|---|---|
| 12:00 AM (midnight) | 00:00 |
| 1:00 AM | 01:00 |
| 12:00 PM (noon) | 12:00 |
| 1:00 PM | 13:00 |
| 6:00 PM | 18:00 |
| 11:59 PM | 23:59 |
Timestamps to dates
Use the epoch converter to instantly translate Unix timestamps to human-readable dates and back. The converter handles both seconds and milliseconds formats automatically.
Tips
- Use ISO 8601 when exchanging data — it is unambiguous, sorts correctly as a string, and is the standard for JSON APIs.
- Store times in UTC — convert to local time only for display. This prevents timezone bugs when users are in different regions.
- Remember JavaScript uses milliseconds —
Date.now()returns milliseconds, not seconds. Divide by 1000 to get a standard Unix timestamp. - Bookmark the converter — if you work with APIs or logs, timestamp conversion is something you will do repeatedly.
Frequently Asked Questions
What is ISO 8601 format?
ISO 8601 is the international standard for date and time representation. It looks like 2026-04-07T14:30:00Z, where T separates date and time, and Z indicates UTC. It is unambiguous regardless of locale.
Why do APIs use Unix timestamps instead of readable dates?
Unix timestamps are a single number, making them easy to store, sort, and compare. They are timezone-neutral (always UTC) and take up less space than formatted date strings. The tradeoff is that they are not human-readable.
What does the Z mean at the end of a timestamp?
The Z stands for "Zulu time," which is another name for UTC (Coordinated Universal Time). A timestamp ending in Z is in UTC, not local time.
How do I convert 24-hour time to 12-hour?
For hours 1-12, the time stays the same (add AM for 0-11, PM for 12). For hours 13-23, subtract 12 and add PM. 00:00 is 12:00 AM (midnight). 12:00 is 12:00 PM (noon).