function getPreviousDate(numOfDays) {
var date = new Date()
date.setDate(date.getDate() - numOfDays)
var year = date.getFullYear()
var month = ("0" + (date.getMonth() + 1)).slice(-2)
var day = ("0" + date.getDate()).slice(-2)
var hour = ("0" + date.getHours()).slice(-2)
var minutes = ("0" + date.getMinutes()).slice(-2)
var seconds = ("0" + date.getSeconds()).slice(-2)
// return year + "-" + month + "-" + day // 年月日
return year + "-" + month + "-" + day +' '+ hour +':'+ minutes +':'+ seconds
}
获取前多少天的年月日,时分秒
最新推荐文章于 2024-09-10 10:21:38 发布