当前位置:网站首页>js 操作在当前日期加减(天、周、月、年数)
js 操作在当前日期加减(天、周、月、年数)
2022-07-30 04:16:00 【黎&&轩】
1.当前时间的15天后
getNextDay () {
let nowDate = new Date()
nowDate.setDate(nowDate.getDate() + 15)
return nowDate
}
Date本来就有setDate()的方法 ,用getDate()出来的数值+15就是加15天 如果大于本月最大天数会自动往下加一个月的
//创建date变量
var nowDate = new Date();
//添加天数
nowDate.setDate(nowDate.getDate() + 1);
//添加周 添加周没有特定的获取周的方法,所以用添加天的方式,来添加七天,即为一周
nowDate.setDate(nowDate.getDate() + 7);
//添加月数
nowDate.setMonth(nowDate.getMonth() + 1);
//添加年数
nowDate.setYear(nowDate.getYear() + 1);
之前时间的话替换成 “-” 号
边栏推荐
- 【C进阶】数组传参与函数指针
- Taobao/Tmall get Taobao store details API
- Flink学习第一天——什么是批量、流式计算?
- 2.4希尔排序
- [ 云原生之谜 ] 云原生背景 && 定义 && 相关技术详解?
- Drools (7): WorkBench
- (题目练习)条件概率+权值线段树+FWT+后缀数组
- Pytorch framework to study record 6 - the torch. Nn. The Module and the torch nn. Functional. The use of conv2d
- What are Redis server startup after the operation?
- SQL Server data type conversion function cast () and convert () explanation
猜你喜欢

Redis server启动后会做哪些操作?

【Untitled】

图像视角矫正之透视变换矩阵(单应矩阵)/findHomography 与 getPerspectiveTransformd的区别

Pytorch框架学习记录7——卷积层

Roperties class configuration file & DOS to view the host network situation

Pytorch框架学习记录2——TensorBoard的使用

Charles replaces the interface response information
![[Node accesses MongoDB database]](/img/00/41000fc7a038f4d46151ab479174b9.png)
[Node accesses MongoDB database]

redis分布式锁的原子保证

逆向理论知识3【UI修改篇】
随机推荐
MySQL String Concatenation - Various String Concatenation Practical Cases
day10--install mysql on linux
swagger使用教程——快速使用swagger
Pytorch框架学习记录4——数据集的使用(torchvision.dataset)
error: The following untracked working tree files would be overwritten by
Many overseas authoritative media hotly discuss TRON: laying the foundation for the decentralization of the Internet
How does the Snapdragon 7 series chip perform?Reno8 Pro proves a new generation of God U
cnpm安装步骤
Pytorch framework learning record 3 - the use of Transform
Charles 替换 接口响应信息
【C进阶】数组传参与函数指针
1. 获取数据-requests.get()
OA Project Pending Meeting & History Meeting & All Meetings
Mini Program Graduation Works WeChat Points Mall Mini Program Graduation Design Finished Product (2) Mini Program Function
05全局配置文件application.properties详解
Pytorch framework learning record 4 - the use of datasets (torchvision.dataset)
The difference between forward and redirect
新型LaaS协议Elephant Swap给ePLATO提供可持续溢价空间
Azure 开发者新闻快讯丨开发者7月大事记一览
恐造成下一个“千年虫”的闰秒,遭科技巨头们联合抵制