// let time = new Date('2019-12-12 21:00').getHours()
// let time = new Date('2019-12-12 21:00').getMinutes()
let hour = new Date('21:00')
let time = new Date('2019-12-12 21:00').getTime()/1000
let time2 = new Date('2019-12-12 21:00').valueOf()/1000
let time3 = Date.parse(new Date('2019-12-12 21:00'))/1000
// console.log(hour)
// console.log(time,time2,time3)
function someDaySomeTime(n, time) {
// 将传入时间字符串转为数组
var timeArr = time.split('/')
// 获取当前时间戳
var today = new Date();
// 将当天时间戳设为0点0分0秒
today.setHours(0),
today.setMinutes(0);
today.setSeconds(0);
today.setMilliseconds(0);
console.log(today)
// 计算一天的毫秒数
var oneDay = 1000 * 60 * 60 * 24
// 获取指定天的时间戳 前面传负数
var someDay = new Date(today.getTime() + oneDay*n)
// 将指定天的时分秒设为我们指定的值
someDay.setHours(Number(timeArr[0]))
someDay.setMinutes(Number(timeArr[1]))
today.setSeconds(Number(timeArr[2]));
someDay.setMilliseconds(0);
return someDay
}
console.log(someDaySomeTime(-2, '10/20/30'))
console