グローバルツールハブ
現在の言語: Japanese
ガイド一覧へ戻る

ガイド

APIの日付とUnixタイムスタンプが一致しない理由

APIの日付文字列とUnix timestampの不一致を素早く切り分ける実践ガイドです。

同じレスポンス内でも日付文字列とtimestampが一致しないことがあります。多くはタイムゾーン処理や丸め、生成元フィールドの違いが原因です。

Understand that fields may have different origins

APIs often include both an event timestamp and a display-ready date.

Those values can be generated at different pipeline steps and are not always exact mirrors.

Check whether the Unix value is seconds or milliseconds

Unit mismatch is still the fastest way to create a fake disagreement.

Confirm digit length before comparing with readable date output.

Verify timezone handling on both fields

A date string may include offset information while a Unix timestamp is timezone-neutral.

If one field was formatted in local server time, differences can appear immediately.

  • Look for Z, +09:00, -05:00 style suffixes.
  • Confirm whether backend formatting uses UTC or local timezone.
  • Test conversion in UTC and local views.

Watch for rounding and truncation behavior

Some APIs round to seconds while others preserve milliseconds.

Small truncation differences can become visible in sorted tables and incident timelines.

Use one known sample to validate assumptions

Pick a record with a known real event time and compare every field from storage to UI.

This quickly shows whether mismatch comes from API generation or frontend rendering.

Use this guide when

  • Two date fields in one API response disagree.
  • Backend logs and dashboard time labels do not align.
  • You need to explain a time mismatch to teammates quickly.
  • A timestamp seems correct but the rendered date looks shifted.

Compare source, unit, and timezone together

Treat each date field as separate data until you confirm origin, unit, and timezone assumptions.

関連ツール

タイムスタンプ変換

Unix秒、Unixミリ秒、日時テキストをブラウザ内で双方向に変換できます。

Open Timestamp Converter

あわせて読みたいガイド

近い作業フローを扱う別の短い記事も確認できます。