js 获取未来日期距离当前日期的毫秒数

 

 

handleBtnClick () {
      // 当前时间
      var currentTime= parseInt(new Date().getTime()/1000);
      // 未来时间
      var futureTime = parseInt(new Date('2020/04/03 17:50:00').getTime()/1000);
      
      if (futureTime <= currentTime) {
        this.time = 0;
        return false;
      } else {
        // 这里把秒数转成毫秒
        this.time = (futureTime - currentTime) * 1000;
        console.log(this.time, '3');
      }
    }

 

posted @ 2020-04-02 17:55  本溢  阅读(515)  评论(0)    收藏  举报