ガイド
秒とミリ秒のタイムスタンプ不具合を素早く見つける方法
seconds/milliseconds混在バグを短い手順で切り分けるガイドです。
タイムスタンプ不具合は最初の確認順が大切です。短い単位チェックだけで長い調査を避けられます。
Start with the visual digit test
Most seconds timestamps are 10 digits and milliseconds are 13 digits.
This quick check solves many issues before deeper debugging.
Use one expected real-world timestamp
Convert one value where you already know the event time.
If result year or hour is absurd, unit is likely wrong.
Check both conversion directions
Convert timestamp to date and date back to timestamp.
Round-trip checks expose hidden assumptions in parsing logic.
- Run test in UTC view.
- Run same value in local view.
- Compare with backend log output.
Inspect JavaScript and backend defaults
JavaScript Date constructors often expect milliseconds.
Many backend stores and APIs use seconds by default, so integration points need explicit conversion.
Add a guardrail for future payloads
Document expected unit in schema and enforce it with validation checks.
A small validator can stop repeated bugs across services.
Great for
- Dates unexpectedly near 1970.
- Future dates far beyond expected range.
- APIs and frontend showing different event times.
- Reviewing suspicious timestamps in incident logs.
Digit length check saves time
Start with digit length, then confirm one known value in UTC and local time.