暗黑模式
操作
dateuts 支持对日期进行操作。
大多数方法的返回值都是 dateuts 对象实例,可以链式调用 format 方法对日期进行格式化,如:
ts
dateuts().add(3, 'day').subtract(1,'year').format('YYYY-MM-DD HH:mm:ss')增加
返回增加一定时间的复制的 dateuts 对象。支持的单位列表见下
ts
dateuts().add(3, 'day')减少
返回减少一定时间的复制的 dateuts 对象。支持的单位列表见下
ts
dateuts().subtract(3, 'day')时间的开始
返回复制的 dateuts 对象,并设置到一个时间的开始
ts
const d=dateuts('2025-03-15').startOf('year')
//格式化之后的时间为:2025-01-01 00:00:00
d.format('YYYY-MM-DD HH:mm:ss')时间的结束
返回复制的 dateuts 对象,并设置到一个时间的末尾
ts
const d=dateuts('2025-03-15').endOf('year')
//格式化之后的时间为:2025-12-31 23:59:59
d.format('YYYY-MM-DD HH:mm:ss')支持的单位列表
| 单位 | 说明 |
|---|---|
| year | 年 |
| month | 月 |
| day | 日 |
| week | 周 |
| quarter | 季度 |
| hour | 小时 |
| minute | 分钟 |
| second | 秒 |
| millisecond | 毫秒 |
