zoukankan      html  css  js  c++  java
  • 倒计时

    // 倒计时
        countdown() {
          var reg = /^d{2}$/
          var ending = new Date(this.days)
          var now = new Date()
          if (now >= ending) {
            clearTimeout(this.timeout)
            return
          }
          var disc = ending - now
          this.hour = parseInt(disc / 1000 / 60 / 60 % 24)
          this.hour = !reg.test(this.hour) ? '0' + this.hour : this.hour
          this.minutes = parseInt(disc / 1000 / 60 % 60)
          this.minutes = !reg.test(this.minutes) ? '0' + this.minutes : this.minutes
          this.seconds = parseInt(disc / 1000 % 60)
          this.seconds = !reg.test(this.seconds) ? '0' + this.seconds : this.seconds
          this.timeout = setTimeout(this.countdown, 1000)
          return this.minutes
        },
        // 当前时间往后固定时间
        getTime(day) {
          var today = new Date()
          var endMouth = today.getMonth() + 1
          if (endMouth < 10) {
            endMouth = '0' + endMouth
          }
          var beforMilliseconds = today.getTime() + 1000 * 3600 * 24 * day
          var beforday = new Date()
          beforday.setTime(beforMilliseconds)
          var strYear = beforday.getFullYear()
          var strDay = beforday.getDate()
          var strMonth = beforday.getMonth() + 1
          let hour = beforday.getHours()
          let minute = beforday.getMinutes()
          let second = beforday.getSeconds()
          if (strMonth < 10) {
            strMonth = '0' + strMonth
          }
          return strYear + '/' + strMonth + '/' + strDay + ' ' + hour + ':' + minute + ':' + second
        },
    created() {
        this.days = this.getTime(0.03125)
      },
  • 相关阅读:
    舌尖上的中关村
    解决winform窗体闪烁问题
    24段魔尺,可以折出哪些精美图案(续)
    24段魔尺,可以折出哪些精美图案
    关于Python编程的一些问答
    BZOJ 1025: [SCOI2009]游戏
    BZOJ 1025: [SCOI2009]游戏
    BZOJ 1207: [HNOI2004]打鼹鼠
    BZOJ 1207: [HNOI2004]打鼹鼠
    BZOJ 1046: [HAOI2007]上升序列
  • 原文地址:https://www.cnblogs.com/taochengyong/p/14337990.html
Copyright © 2011-2022 走看看