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