let now = new Date() // 获取当前时间
let now1 = new Date('2020-05-21 16:25:23') // 设定时间
console.log(now1)
// 设定时间
now.setHours() // 设定小时为
now.setDate() // 设定时间 ('这里填写内容')
now.getTime() // 时间戳
console.log(+new Date) // 1970年至今的毫秒数
let yy = now.getFullYear() // 获取 年份
let mm = now.getMonth() + 1 // 获取当前时间的 月份
let dd = now.getDate() // 获取当前时间的 日
let hh = now.getHours() // 获取当前时间的 小时
let mi = now.getMinutes() // 获取当前时间的 分
let ss = now.getSeconds() // 获取当前时间的 秒
let ww = now.getDay() // 获取当前时间的 星期
// let ww = '星期' + '日一二三四五六'[now.getDay()]
// console.log(ww)
// 时间节流
let i = 0;
let endTime = new Date()
function sayHi() {
i++
if (new Date() - endTime < 1000) {
return false;
}
console.log('hi', i)
endTime = new Date()
}