What Is a Time Stamp? Formats, Milliseconds and Examples
A time stamp records when something happened. Learn what timestamps look like, how milliseconds are written, how US clock notation differs, and how to check one.
A time stamp, also written as one word, timestamp, is a piece of text or a number that records when something happened. It turns a moment in time into a fixed, readable or machine-parsable string. You will find time stamps in log files, file metadata, database records, chat messages, photo details and file names. Both spellings are correct. "Timestamp" is the usual form in software and technical documentation.
What a time stamp does for your text
The input is a moment in time. The output is a string written in a defined format. A useful time stamp answers three questions: which date, which time of day, and which clock it was measured on, meaning the time zone or offset from Coordinated Universal Time (UTC). If the clock is missing, the time stamp is ambiguous. For example, 17:13 in New York and 17:13 in London are different moments.
Time stamps come in two broad kinds. Machine-oriented time stamps, such as Unix time and ISO 8601 strings, are meant for sorting, storing and exchanging between systems. Human-oriented time stamps use local clock notation, such as 11/14/2023 5:13:20 PM in the US. Most text problems happen when these two kinds get mixed, or when one is converted to the other without its time zone.
What does a timestamp look like
The illustrative example below writes one moment in six common ways. The local versions assume US Eastern Time, which is five hours behind UTC on that date.
Unix time (seconds): 1700000000
Unix time (milliseconds): 1700000000000
ISO 8601, UTC: 2023-11-14T22:13:20Z
ISO 8601 with offset: 2023-11-14T17:13:20-05:00
US 12-hour notation: 11/14/2023 5:13:20 PM
24-hour local notation: 2023-11-14 17:13:20
| Format | Example | Best for | Watch out for |
| Unix time (seconds) | 1700000000 | Storage, APIs, calculations | Not human-readable; seconds and milliseconds are easily confused |
| Unix time (milliseconds) | 1700000000000 | JavaScript and many web APIs | Has three more digits than the seconds form |
| ISO 8601 / RFC 3339 | 2023-11-14T22:13:20Z | Logs, data exchange, sorting as text | Omitting Z or the offset makes it ambiguous |
| US clock notation | 11/14/2023 5:13:20 PM | Display to US readers | Month/day order and AM/PM; does not sort correctly as text |
| 24-hour local notation | 2023-11-14 17:13:20 | Display in many regions | Usually lacks a time zone |
Reading an ISO 8601 time stamp
- 2023-11-14: the date, ordered as year-month-day
- T: the separator between the date and the time
- 22:13:20: hours, minutes and seconds on a 24-hour clock
- Z: the time is in UTC (zero offset)
- -05:00, used in place of Z: the local time is five hours behind UTC
Because the largest unit comes first and every field is zero-padded, ISO 8601 strings that share the same offset sort chronologically when you sort them as plain text. This is the main reason they are popular in logs and file names.
Reading a Unix timestamp
A Unix timestamp counts the seconds that have elapsed since the Unix epoch, which is 1970-01-01 00:00:00 UTC. Leap seconds are not counted. The number is the same everywhere in the world. A time zone is applied only when the number is converted for display. Present-day values in seconds are ten digits long.
Timestamp with milliseconds
There are two common ways to add millisecond precision. You can append a fractional part to a text time stamp, or you can count milliseconds instead of seconds since the epoch. Both lines in this illustrative example represent the same moment.
2023-11-14T22:13:20.123Z
1700000000123
In text form, the fraction follows the seconds. ISO 8601 permits either a period or a comma as the decimal sign, but the period is far more common in software. The number of digits shows the precision: three digits for milliseconds, six for microseconds and nine for nanoseconds. In epoch form, present-day millisecond values are thirteen digits long. Dividing by 1000 gives seconds. Tools differ on their default unit. For example, JavaScript's Date.now() returns milliseconds, while the Unix command date +%s prints seconds. Check which unit a field expects before you paste a value into it.
A wrong unit leaves a recognizable symptom. A ten-digit seconds value that is read as milliseconds turns into a date in January 1970. A thirteen-digit milliseconds value that is read as seconds lands tens of thousands of years in the future. If a converted date looks absurd, count the digits first.
Clock notation and localization
Human-readable time stamps follow local conventions. US notation normally puts the month before the day and uses a 12-hour clock with AM and PM. Many other regions put the day first and use a 24-hour clock. A string such as 03/04/2024 can therefore mean March 4 or April 3, depending on the reader. When a time stamp will be read in more than one region, write out the month name or use ISO 8601.
- 12:00 AM is midnight and 12:00 PM is noon. On a 24-hour clock these are 00:00 and 12:00.
- Leading zeros vary. US display often writes 5:13 PM, while 24-hour and ISO formats write 05:13 or 17:13.
- The AM and PM markers, and where they go, depend on the language and locale. Do not hard-code them when you parse text from other locales.
- Some localization libraries put a narrow no-break space (U+202F) before AM or PM instead of a regular space (U+0020). The two look the same on screen, but exact-match searches and strict parsers treat them as different characters.
5:13:20 PM <- regular space, U+0020
5:13:20<U+202F>PM <- narrow no-break space, shown as a code point
A safe rule is to store and exchange time stamps in a machine format, either Unix time or ISO 8601 with Z or an offset, and to convert to local clock notation only when you display them. This keeps the underlying moment intact. A localization change then cannot alter its meaning.
How to write a time stamp step by step
- 1. Decide who reads it. Use ISO 8601 or Unix time for software and data. Use local clock notation for people.
- 2. Choose a precision: seconds, milliseconds or finer. Keep the same precision throughout a file or dataset.
- 3. Fix the time zone. Write Z for UTC or a numeric offset such as -05:00. Avoid abbreviations like EST when exactness matters, because some abbreviations are shared by different zones.
- 4. Pick one format and apply it consistently, with zero-padded fields.
- 5. For file names, leave out colons, because some operating systems do not allow them. A compact form such as 20231114T221320Z keeps the ISO order without colons or dashes.
- 6. Check the result using the steps below.
How to check the result
- Convert the time stamp back to a readable date and confirm that you get the moment you intended.
- Count the digits of an epoch value: ten for seconds and thirteen for milliseconds, for present-day dates.
- Confirm that Z or an offset is present, and that it matches the zone the time was recorded in.
- Do a round trip: format the time, parse the string, then format it again. The output should be identical.
- If an exact match fails on text that looks correct, inspect the characters by code point to find invisible differences such as U+202F.
This guide covers general conventions only. No documentation for a specific tool was provided, so a given application's default units, available format options and locale-specific output should be confirmed in that application's own documentation.