Formattazione
Ottieni una rappresentazione formattata della durata, basata sulla stringa di token fornita.
Per eseguire l'escape di caratteri speciali, racchiudili tra parentesi quadre (es. [MM]
).
js
dayjs
.duration({
seconds: 1,
minutes: 2,
hours: 3,
days: 4,
months: 6,
years: 7,
})
.format('YYYY-MM-DDTHH:mm:ss'); // 0007-06-04T03:02:01
Elenco di tutti i formati disponibili
Formato | Output | Descrizione |
---|---|---|
Y | 18 | Anno |
YY | 18 | Anno, 2 cifre |
YYYY | 2018 | Anno, 4 cifre |
M | 1-12 | Mese, da 1 a 12 |
MM | 01-12 | Mese, 2 cifre |
D | 1-31 | Giorno del mese |
DD | 01-31 | Giorno del mese, 2 cifre |
H | 0-23 | Ora (formato 24 ore) |
HH | 00-23 | Ora (formato 24 ore), 2 cifre |
m | 0-59 | Minuto |
mm | 00-59 | Minuto, 2 cifre |
s | 0-59 | Secondo |
ss | 00-59 | Secondo, 2 cifre |
SSS | 000-999 | Millisecondo, 3 cifre |