ISO-8601 Duration Format in a Nutshell
ISO-8601 Duration Format
ISO-8601 standardizes how we represent durations in a compact, unambiguous way. The basic structure for durations is:
P[n]Y[n]M[n]DT[n]H[n]M[n]S
Breakdown:
- P: Marks the start of the duration period.
- [n]Y: Number of years.
- [n]M: Number of months (before the T separator).
- [n]W: Number of weeks.
- [n]D: Number of days.
- T: Separates the date components from the time components.
- [n]H: Number of hours.
- [n]M: Number of minutes (after T, M now means minutes).
- [n]S: Number of seconds.
Quick Examples:
PT30M- P + T indicates a time duration.
- 30M means 30 minutes.
P1DT2H- 1 day and 2 hours.
PT15M30S- 15 minutes and 30 seconds.
This concise notation is widely used in various frameworks (like ShedLock) and systems to ensure clarity and consistency when specifying time durations.