Tempo/Numeri
Analizzatore di durata ISO 8601
Analizza una stringa come "P3Y6M4DT12H30M5S" in un formato leggibile, oppure componi una stringa del genere da anni/mesi/giorni/ore/minuti/secondi.
Un campo vuoto = 0; i campi a zero non vengono inclusi nella stringa. La componente settimane (P4W) è supportata solo in analisi — per comporre usa i giorni.
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.
Articolo su questo strumento: ISO 8601 Duration: come scrivere una durata in formato standard
Domande frequenti
Cosa significa una stringa come P3Y6M4DT12H30M5S?
Questo è il formato di durata standard ISO 8601: P significa "period" (periodo), seguito da anni/mesi/giorni fino alla lettera T, dopo la quale vengono ore/minuti/secondi. In questo esempio sono 3 anni, 6 mesi, 4 giorni, 12 ore, 30 minuti e 5 secondi.
In cosa differisce una durata ISO da una semplice durata in ore?
A differenza delle unità fisse (come nel calcolatore di durata), i componenti "anni" e "mesi" qui sono basati sul calendario e non hanno un numero fisso di secondi — la loro lunghezza esatta dipende dalle date specifiche a cui vengono applicati.
Il formato settimanale P4W è supportato?
Sì, ma solo quando si analizza una stringa esistente. Quando costruisci la tua stringa, le settimane devono essere espresse in giorni, poiché ISO 8601 non permette di combinare settimane con altri componenti in un'unica stringa.
Posso indicare secondi o minuti frazionari?
Sì, lo standard consente una parte frazionaria solo nell'ultimo componente della stringa — ad esempio PT1.5S (1,5 secondi) o PT1H30.5M (1 ora 30,5 minuti) sono validi, ma una parte frazionaria in un componente diverso dall'ultimo no.
Esistono durate ISO negative?
Lo standard ISO 8601 di base non definisce un segno per le durate, ma alcune implementazioni (incluso questo strumento) supportano un segno meno iniziale per indicare "fa" o una durata invertita — un'estensione comune, anche se non ufficiale.