var nowdays = new Date()
var year = nowdays.getFullYear()
var month = nowdays.getMonth()
if (month == 0) {
month = 12
year = year - 1
}
if (month < 10) {
month = '0' + month
}
var myDate = new Date(year, month, 0)
var startDate = year + '-' + month + '-01 00:00:00' //上个月第一天
var endDate = year + '-' + month + '-' + myDate.getDate() + ' 23:59:00' //上个月最后一天
console.log(endDate)
var time3 = Date.parse(endDate)
console.log(time3)
js获取上一个月的第一天和最后一天并且转换为时间戳
最新推荐文章于 2023-06-01 17:20:25 发布