timestamp (gcReportTime) { // 1577948059000
var date = new Date(gcReportTime)
var year = date.getFullYear()
var month = this.Appendzero(date.getMonth() + 1)
var day = this.Appendzero(date.getDate())
return year + '-' + month + '-' + day // 2020-01-02
},
2019-05-14
Appendzero(obj) { // 缺0补齐
if (obj < 10) return "0" + "" + obj;
else return obj;
},
修改于2020-1-19
或者
formartDate (param) {
// 时间戳转字符串
let date = new Date(param)
let Y = date.getFullYear() + '-'
let M = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) + '-' : date.getMonth() + 1 + '-'
let D = date.getDate() < 10 ? '0' + date.getDate() + ' ' : date.getDate() + ' '
// let h = date.getHours() < 10 ? '0' + date.getHours() + ':' : date.getHours() + ':'
// let m = date.getMinutes() < 10 ? '0' + date.getMinutes() + ':' : date.getMinutes() + ':'
// let s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
return Y + M + D
}
2020-6-1
date.setTime(date.getTime() + 3600 * 1000 * 24 * Number(this.temp.standardDays))
毫秒 X天
if (this.temp.standardDays) {
console.log(this.temp.standardDays) // 10 (天)
console.log(val) // 2020-06-27 00:00:00
const date = new Date(val)
console.log(date) // Sat Jun 27 2020 00:00:00 GMT+0800 (中国标准时间)
date.setTime(date.getTime() + 3600 * 1000 * 24 * Number(this.temp.standardDays))
console.log(date) // Tue Jul 07 2020 00:00:00 GMT+0800 (中国标准时间)
this.temp.estimateDate = date
}
X天后的日期