RelativeTime
RelativeTime 增加了 .from .to .fromNow .toNow 4 个 API 来展示相对的时间 (e.g. 3 小时以前).
var relativeTime = require("dayjs/plugin/relativeTime");
// import relativeTime from 'dayjs/plugin/relativeTime' // ES 2015
dayjs.extend(relativeTime);
dayjs().from(dayjs("1990-01-01")); // in 31 years
dayjs().from(dayjs("1990-01-01"), true); // 31 years
dayjs().fromNow();
dayjs().to(dayjs("1990-01-01")); // "31 years ago"
dayjs().toNow();
距离现在的相对时间 .fromNow(withoutSuffix?: boolean)
返回 string 距离现在的相对时间
距离 X 的相对时间 .from(compared: Dayjs, withoutSuffix?: boolean)
返回 string 距离 X 的相对时间
到现在的相对时间 .toNow(withoutSuffix?: boolean)
返回 string 到现在的相对时间
到 X 的相对时间 .to(compared: Dayjs, withoutSuffix?: boolean)
返回 string 到 X 的相对时间
