内置对象-Date

  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()
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值