教程 dayjs tutorial

Add

返回增加一定时间的复制的 Day.js 对象。

javascript
const a = dayjs()
const b = a.add(7, 'day')

// a -> the original value and will not change
// b -> the manipulation result
各个传入的单位对大小写不敏感,支持缩写和复数。 请注意,缩写是区分大小写的。

支持的单位列表

单位 缩写 详情
day d 日
week w 周
month M 月
quarter Q 季度 ( 依赖 QuarterOfYear 插件 )
year y 年
hour h 小时
minute m 分钟
second s 秒
millisecond ms 毫秒

或者,也可以给 Day.js 对象增加一个 持续时间。