export const addTime = (strDate, strFlag, value) => {
if(strFlag == 'H') {
value = value * 60 * 60
} else if(strFlag == 'D') {
value = value * 60 * 60 * 24
} else if(strFlag == 'M' || strFlag == 'Y') {
value = 0
}
var dataCurPar = Date.parse(new Date(strDate)) / 1000// 转换为时间戳
dataCurPar = dataCurPar + value// 加5天后的时间戳
var dataDefPar = new Date(parseInt(dataCurPar) * 1000)// 转换为时间
var year = dataDefPar.getFullYear()
var month = dataDefPar.getMonth() + 1
if(strFlag == 'M') {
year = month === 12 ? year + 1 : year
month = month === 12 ? 1 : month + 1
}
if(strFlag == 'Y') {
year = year + 1
}
var month = month < 10 ? '0' + month : month
var Day = dataDefPar.getDate() < 10 ? '0' + dataDefPar.getDate() : dataDefPar.getDate()
var Hours = dataDefPar.getHours() >= 10 ? dataDefPar.getHours() : '0' + dataDefPar.getHours()
var Minutes = dataDefPar.getMinutes() >= 10 ? dataDefPar.getMinutes() : '0' + dataDefPar.getMinutes()
var Seconds = dataDefPar.getSeconds() >= 10 ? dataDefPar.getSeconds() : '0' + dataDefPar.getSeconds()
var dataDef = year + '-' + month + '-' + Day + ' '
+ Hours + ':' + Minutes + ':' + Seconds
return dataDef
}
08-05
1万+