当前位置:网站首页>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);
之前时间的话替换成 “-” 号
边栏推荐
- OA Project Pending Meeting & History Meeting & All Meetings
- MySQL 字符串拼接 - 多种字符串拼接实战案例
- 【翻译】Envoy Fundamentals,这是一个培训课程,使人们能够更快地采用Envoy Proxy。...
- Pytorch框架学习记录7——卷积层
- [ 云原生之谜 ] 云原生背景 && 定义 && 相关技术详解?
- phpoffice edit excel document
- 【C语言】程序环境和预处理
- Is the end of the universe a bank?Talk about those things about doing software testing in the bank
- 基于OpenCV实现的图像拼接(配准)案例
- Reverse Analysis Practice 2
猜你喜欢

Unity3D Application模拟进入前后台及暂停

How to Effectively Conduct Retrospective Meetings (Part 1)?

Redis "super explanation!!!!!!"

数据库概论 - MySQL的简单介绍

Atomic Guarantees of Redis Distributed Locks

How to solve the error "no such file or directory" when EasyCVR starts?

精品MySQL面试题,备战八月99%必问!过不了面试算我的

2.6归并排序

Detailed transport layer

Forum management system
随机推荐
Is the end of the universe a bank?Talk about those things about doing software testing in the bank
MNIST of Dataset: MNIST (handwritten digital image recognition + ubyte.gz file) data set introduction, download, usage (including data enhancement) detailed guide
cv2.polylines
forward与redirect的区别
Redis server启动后会做哪些操作?
day10--install mysql on linux
数组和结构体
WEB 渗透之信息收集
Go书籍大全-从初级到高级以及Web开发
High Concurrency Framework Disruptor
@ WebServlet annotations (Servlet annotations)
图像视角矫正之透视变换矩阵(单应矩阵)/findHomography 与 getPerspectiveTransformd的区别
PyG builds R-GCN to realize node classification
PyG搭建R-GCN实现节点分类
OA Project Pending Meeting & History Meeting & All Meetings
弘玑再度入围Gartner 2022 RPA魔力象限并实现位置大幅跃升
(redistribute, special comprehensive experiment ospf area)
1. 获取数据-requests.get()
Atomic Guarantees of Redis Distributed Locks
Charles 替换 接口响应信息