Converting Timestamps Between Seconds and Milliseconds

How converting a Unix timestamp to milliseconds or back to seconds works, what it changes, where precision is lost, and how to keep results readable after copying.

A Unix timestamp records a moment as a count of time units since 1970-01-01 00:00:00 UTC. Some systems count in seconds and others in milliseconds, so the same moment can appear as two different numbers. This review covers what converting between the two changes, when the conversion is safe, and when a human-readable date should replace or accompany the raw number.

Is This Conversion Suitable for Your Use?

Converting to milliseconds is suitable when the destination expects millisecond values, such as JavaScript's Date constructor or Date.now(). Going from seconds to milliseconds loses nothing, because the only change is multiplying by 1,000. The decisive tradeoff runs in the other direction: converting milliseconds to seconds drops any sub-second part unless you keep a fractional result.

A raw timestamp in either unit is a poor choice when people need to read it. For logs that people review, shared messages, documentation or any accessible interface, show a formatted date and time with an explicit time zone, and keep the numeric timestamp only where software needs it.

What the Conversion Actually Changes

Despite appearing in text-tool collections, this is not a text transformation. Nothing is reversed, mirrored, restyled or substituted at the character level. The conversion changes the unit of a number while the moment it represents stays the same. The stored digits change, but the meaning is preserved as long as the reader or program knows which unit applies.

  • Seconds to milliseconds: multiply by 1,000. Precision is fully preserved.
  • Milliseconds to seconds: divide by 1,000. Either keep the decimal fraction or round, which discards the sub-second part.
  • Time zone: unchanged. Both forms count from the same UTC reference, and time zones only matter when the value is formatted as a local clock time.
  • Clock notation: unchanged. Whether a date displays as 24-hour or 12-hour time, or in a regional date order, depends on the formatting step, not on the unit conversion.

Here is an illustration using the same moment, 2023-11-14 22:13:20 UTC, in both units:

seconds:       1700000000
milliseconds:  1700000000000

1700000000 * 1000    = 1700000000000
1700000000000 / 1000 = 1700000000

Telling the Units Apart

For dates between September 2001 and November 2286, a timestamp in seconds has 10 digits, and the same moment in milliseconds has 13 digits. This digit-count check is a useful heuristic but not a guarantee. Dates before 2001 have fewer digits, and some systems use microseconds (16 digits for current dates) or nanoseconds (19 digits). When the unit is not documented, compare a converted value against a date you already know.

Rounding Choices When Reducing to Seconds

Dropping the fraction can be done by flooring, truncating toward zero, or rounding to the nearest second. For moments after 1970 the first two give the same result. For negative timestamps, which represent moments before 1970, they differ by one second. Pick one method deliberately and use it everywhere.

// JavaScript
const ms = Date.now();                 // milliseconds
const sec = Math.floor(ms / 1000);     // whole seconds, floors negatives
const msAgain = sec * 1000;            // sub-second part is gone

# Python
import time
sec = time.time()                      # seconds, as a float
ms = int(sec * 1000)                   # int() truncates toward zero
sec_whole = ms // 1000                 # // floors, including negatives

Will the Result Stay Readable and Usable After Copying?

A timestamp is plain ASCII digits, so copying and pasting it will not change its characters the way styled Unicode text can. The risks lie elsewhere: the unit can be lost, and the receiving program may interpret the value differently.

  • Unit ambiguity: a bare number carries no label. If it is pasted into a field that expects the other unit, the result is a date that is wrong by a factor of 1,000. Interpreting milliseconds as seconds pushes the date tens of thousands of years into the future, and interpreting seconds as milliseconds lands it in January 1970. Label the unit in field names, column headers or surrounding text.
  • Numeric limits: 13-digit millisecond values fit within JavaScript's safe-integer range and within the 15 significant digits that common spreadsheets keep. Nanosecond values for current dates exceed both, so they can be silently rounded when parsed as ordinary numbers. Treat very long timestamps as strings or use a 64-bit integer type.
  • Spreadsheet display: a spreadsheet may show a long number in scientific notation or apply a format you did not choose. Check the cell format before you rely on what you see.
  • Search and matching: searching for the seconds form will not find the milliseconds form of the same moment. Normalize to one unit before you compare or search records.
  • Editing: a mistyped digit still gives a valid-looking timestamp, so errors are easy to miss. A formatted date makes mistakes visible.

Accessibility: a long string of digits gives a listener or reader no useful meaning, whatever a particular screen reader does with it. No assistive-technology testing was available for this review, so no claim is made about how a specific screen reader announces timestamps. The practical rule does not depend on that detail. Anywhere people read the value, provide a formatted date and time with its time zone. Use the semantic time element on web pages, which can carry a machine-readable value next to readable text.

When to Use the Plain Readable Form Instead

  • Messages, tickets and documentation read by people: use a formatted date and time with the time zone stated.
  • International audiences: use an unambiguous format such as ISO 8601 (for example 2023-11-14T22:13:20Z) rather than a regional date order that readers might misread.
  • Data exchange between programs: a numeric timestamp is fine if the unit is documented. Milliseconds suit JavaScript environments, and seconds are common in Unix tools and many APIs.
  • Mixed sources: convert everything to one unit at the boundary where data enters your system, not piecemeal later.

Evidence Gaps

This review rests on general, verifiable behavior of the Unix time convention and common programming languages. No specific converter tool was examined, so nothing is said about any tool's accuracy, interface, privacy or data retention. No scoped tests were run on particular spreadsheets, chat apps or screen readers. Before relying on a destination's behavior with long numbers or timestamp fields, check its documentation or test it with a known value.