Get + Set
Day.js utilizza getter e setter sovraccaricati. Questo significa che chiamare questi metodi senza argomenti li fa comportare come getter, mentre chiamarli con un argomento li fa comportare come setter.
Poiché gli oggetti dayjs sono immutabili, tutti i setter restituiscono una nuova istanza di dayjs.
Questi metodi si riferiscono alla funzione equivalente sull'oggetto Date nativo.
js
dayjs().second(30).valueOf(); // => new Date().setSeconds(30)
dayjs().second(); // => new Date().getSeconds()Se ti trovi in modalità UTC, questi metodi si riferiranno all'equivalente UTC.
js
dayjs.utc().second(30).valueOf(); // => new Date().setUTCSeconds(30)
dayjs.utc().second(); // => new Date().getUTCSeconds()