時間/数値
ISO 8601期間パーサー
"P3Y6M4DT12H30M5S"のような文字列を読みやすい形式に解析、または年/月/日/時/分/秒からそのような文字列を作成。
空欄=0。値が0のフィールドは文字列に含まれません。週コンポーネント(P4W)は解析時のみ対応 — 作成時は日を使用してください。
An ISO 8601 duration (e.g. P3Y6M4DT12H30M5S) is a compact, unambiguous way to write a time span, used by many APIs and data formats, but hard to read without parsing it. This tool translates such a string into plain language and lets you build one from separate fields.
How to use it
- Parse: paste an ISO duration string to get years, months, days, hours, minutes, and seconds broken out separately, in a readable form.
- Build: enter the duration components you need and the tool assembles a valid ISO 8601 string.
- The letter T before the time part (hours/minutes/seconds) is required and gets added automatically when needed.
Common uses
- Reading a duration field from an API response (a subscription, a rental period, a timeout) given in this format.
- Building a correctly formatted ISO 8601 string for a request that expects a duration in exactly this format.
- Debugging why a third-party API's parser rejects a hand-built duration — checking it against the standard's exact syntax.
Things to keep in mind
The leading P stands for "period" and is required, just like the T that separates days from hours in the time part.
The base standard doesn't define a sign for durations — negative durations (to mean "ago") are only supported by specific implementations as an unofficial extension.
よくある質問
P3Y6M4DT12H30M5Sのような文字列は何を意味しますか?
これは標準のISO 8601期間フォーマットです: Pは「period(期間)」を意味し、その後T文字までに年/月/日が続き、その後に時/分/秒が来ます。この例では3年、6か月、4日、12時間、30分、5秒です。
ISO期間は単純な時間の期間とどう違いますか?
固定単位(期間計算機のような)とは異なり、ここでの「年」と「月」の構成要素はカレンダーベースであり、固定の秒数を持ちません — その正確な長さは適用される特定の日付に依存します。
週フォーマットP4Wはサポートされていますか?
はい、ただし既存の文字列を解析する場合のみです。独自の文字列を作成する場合、ISO 8601は1つの文字列内で週を他の構成要素と組み合わせることを許可しないため、週は日数で表す必要があります。
小数秒や小数分を指定できますか?
はい、標準では文字列の最後のコンポーネントにのみ小数部分が許可されています——例えばPT1.5S(1.5秒)やPT1H30.5M(1時間30.5分)は有効ですが、最後以外のコンポーネントの小数部分は無効です。
負のISO期間はありますか?
基本的なISO 8601標準は期間の符号を定義していませんが、一部の実装(このツールを含む)は「〜前」や逆向きの期間を表すために先頭にマイナス記号を付けることをサポートしています——これは一般的ですが非公式な拡張です。