# Debug timestamps: seconds, milliseconds and timezones

> Trace one instant through Unix seconds, milliseconds and ISO offsets. Reject impossible dates and keep local scheduling separate from timestamp conversion.

- Canonical HTML: [https://unrust.dev/blog/unix-seconds-milliseconds-and-timezones](https://unrust.dev/blog/unix-seconds-milliseconds-and-timezones)
- Markdown representation: [https://unrust.dev/blog/unix-seconds-milliseconds-and-timezones/index.md](https://unrust.dev/blog/unix-seconds-milliseconds-and-timezones/index.md)

Published: 2026-10-16. By the Unrust team.

[Open the companion tool](https://unrust.dev/tools/unix-timestamp-converter/index.md)

## Read the unit from the contract

An event arrives with the value 1704067200. Before converting it, inspect the field documentation or producer code. If the unit is seconds, the instant is midnight UTC on 1 January 2024. If the unit is milliseconds, the same digits point to 20 January 1970. Guessing from digit count can hide the bug you are trying to find.

Open the timestamp converter with the sample number. Select seconds, read the UTC result, then select milliseconds without changing the number. The contrast gives you a concrete test case to take back to the event producer. Name internal variables with their units when the boundary is easy to confuse.

```text
Unix seconds:      1704067200
Unix milliseconds: 1704067200000
UTC:               2024-01-01T00:00:00.000Z
```

## An offset changes the clock reading, not the instant

Switch to ISO date input and enter 2024-01-01T01:00:00+01:00. The UTC result is 2024-01-01T00:00:00.000Z, the same instant as the example above. The +01:00 offset says that the written clock is one hour ahead of UTC, so conversion subtracts that hour.

Now enter 2024-01-01T00:00:00+01:00. This is a different instant: 2023-12-31T23:00:00.000Z. A date crossing into the previous day can be correct. Compare absolute instants before treating different displayed calendar dates as a storage error.

## Reject incomplete or impossible dates early

A string such as 2024-01-01T09:00:00 omits the timezone. Its intended instant depends on context that is not present in the string. This converter requires Z or a numeric offset rather than assuming your device’s local zone. It also requires seconds and allows at most three fractional digits.

Try 2024-02-29T12:00:00Z, then change the year to 2023. The first is a valid leap-day instant; the second is rejected. The utility checks calendar fields before conversion so an impossible day cannot silently become a different day. Test those boundaries where dates enter your application, not only in the display layer.

## Keep fractional precision visible

An input of 1234 milliseconds represents 1.234 seconds after the Unix epoch. An input of -1 millisecond represents 1969-12-31T23:59:59.999Z. The result includes both milliseconds and seconds so the fractional part is visible. If your destination accepts whole seconds only, choose an explicit rounding policy instead of dropping the digits accidentally.

This tool accepts whole-number Unix inputs. For a fractional-second instant, use integer milliseconds or an ISO date with millisecond precision. Its supported UTC years are 0000 through 9999. Leap seconds and precision finer than a millisecond are outside its scope.

## Separate event time from future local scheduling

A numeric offset is enough to describe the instant in a timestamp. It does not encode the future daylight-saving rules of a named place. A recurring “09:00 in Dublin” schedule therefore needs a scheduling model and timezone rules, not just the offset observed on the day it was created.

For an event-log bug, keep a small evidence set: the raw value, documented unit, written offset if present, converted UTC value and the display zone. Test the same fixture through ingestion, storage and rendering. The converter helps inspect the boundary; it does not replace the application’s scheduling policy.

## References and next steps

[MDN: Date.parse and date input behavior](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/parse)

[Practice debugging by testing one assumption at a time](https://unrust.dev/guides/debugging-without-ai/index.md)

[Take the free diagnostic without tools or hints](https://unrust.dev/diagnostic/index.md)
