提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
时间提前720小时,一年,一月,一小时
1.js
代码如下(示例):
// 国际标准时间格式化
getYMDHMS (time) {
let year = time.getFullYear()
const month = (time.getMonth() + 1).toString().padStart(2, '0')
const date = (time.getDate()).toString().padStart(2, '0')
const hours = (time.getHours()).toString().padStart(2, '0')
const minute = (time.getMinutes()).toString().padStart(2, '0')
const second = (time.getSeconds()).toString().padStart(2, '0')
return year + '-' + month + '-' + date + ' ' + hours + ':' + minute + ':' + second
},
//提前减去 720 小时
timeRes(formTm){ // formTm = '2018-03-22 16:14:55'
let hour = formTm.setHours(formTm.getHours() -720)//小时
// let sdtime4=new Date().setMonth((new Date().getMonth()-1))//一个月
let res = this.getYMDHMS(new Date(hour))
return console.log('最终的时间',res);
},