RelativeTime
RelativeTime aggiunge le API .from()
, .to()
, .fromNow()
e .toNow()
per formattare le date in stringhe di tempo relative (es. 3 ore fa).
javascript
var relativeTime = require('dayjs/plugin/relativeTime');
// import relativeTime from 'dayjs/plugin/relativeTime' // ES 2015
dayjs.extend(relativeTime);
dayjs().from(dayjs('1990-01-01')); // 31 anni fa
dayjs().from(dayjs('1990-01-01'), true); // 31 anni
dayjs().fromNow();
dayjs().to(dayjs('1990-01-01')); // "31 anni fa"
dayjs().toNow();
Tempo da adesso .fromNow(withoutSuffix?: boolean)
Restituisce una stringa che rappresenta il tempo relativo a partire da ora.
Tempo da X .from(compared: Dayjs, withoutSuffix?: boolean)
Restituisce una stringa che rappresenta il tempo relativo a partire da una data/ora specificata (X).
Tempo ad adesso .toNow(withoutSuffix?: boolean)
Restituisce una stringa che rappresenta il tempo relativo fino ad ora.
Tempo a X .to(compared: Dayjs, withoutSuffix?: boolean)
Restituisce una stringa che rappresenta il tempo relativo fino a una data/ora specificata (X).