<>1、首先 获取当前时间或者自定义一个时间
// 获取系统当前时间 var nowDate = new Date() 输出结果:Thu Dec 09 2021 15:42:07 GMT+0800 (
中国标准时间) // 自定义时间 var diyDate = new Date('2021-12-12') 输出结果:Sun Dec 12 2021 08:00
:00 GMT+0800 (中国标准时间)
<>2、实例 日期加一天
// 自定义时间 var diyDate = new Date('2021-12-12') //加1天 date = new Date(diyDate.
setDate(diyDate.getDate() + 1)); // 拼接日期 yyyy-MM-dd 注意月份要 + 1 date = date.
getFullYear() + "-" + ((date.getMonth() + 1) > 9 ? date.getMonth() + 1 : "0" + (
date.getMonth() + 1)) + "-" + (date.getDate() > 9 ? date.getDate() : "0" + date.
getDate()); //结果 输出日期:2021-12-13
<>3、日期获取方法
getFullYear() 获取四位的年(yyyy) getMonth() 获取月(0-11) getDay() 以数值获取周名(0-6) getDate()
以数值返回天(1-31) getHours() 获取小时(0-23) getMinutes() 获取分(0-59) getSeconds() 获取秒(0-59
)getMilliseconds() 获取毫秒(0-999) getTime() 获取时间(从 1970 年 1 月 1 日至今)
<>4、日期设置方法
setFullYear() 设置年(可选月和日) setMonth() 设置月(0-11) setDate() 以数值(1-31)设置日 setHours()
设置小时(0-23) setMinutes() 设置分(0-59) setSeconds() 设置秒(0-59) setMilliseconds()
设置毫秒(0-999) setTime() 设置时间(从 1970 年 1 月 1 日至今的毫秒数)
————————————————————————————————

技术
下载桌面版
GitHub
百度网盘(提取码:draw)
Gitee
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:766591547
关注微信