Oggetto Dayjs
È possibile creare un oggetto Dayjs specificando alcune unità di tempo all'interno di un oggetto.
TIP
Per funzionare, è necessario il plugin ObjectSupport
js
dayjs.extend(objectSupport);
dayjs({ hour: 15, minute: 10 });
dayjs.utc({ y: 2010, M: 3, d: 5, h: 15, m: 10, s: 3, ms: 123 });
dayjs({
year: 2010,
month: 3,
day: 5,
hour: 15,
minute: 10,
second: 3,
millisecond: 123,
});
dayjs({
years: 2010,
months: 3,
date: 5,
hours: 15,
minutes: 10,
seconds: 3,
milliseconds: 123,
});
Le chiavi day
e date
si riferiscono entrambe al giorno del mese.
dayjs({})
restituisce la data e l'ora correnti.
Si noti che, come in new Date(year, month, date)
, i mesi sono indicizzati a partire da 0 (Gennaio = 0, Febbraio = 1, ecc.).