zoukankan      html  css  js  c++  java
  • 根据开始时间和结束时间实现倒计时效果

        getDate() {
          var time_now_server, time_now_client, time_end, time_server_client;
          time_end = new Date("2020 07 22 18:50:50");//结束的时间
          time_end = time_end.getTime();
          time_now_server = new Date("2020 07 21 16:35:35");//开始的时间
          time_now_server = time_now_server.getTime();
          time_now_client = new Date();
          time_now_client = time_now_client.getTime();
          time_server_client = time_now_server - time_now_client;
          var timeFunction = () => {
            var time_now, time_distance, str_time;
            var time_now = new Date();
            time_now = time_now.getTime() + time_server_client;
            time_distance = time_end - time_now;
            if (time_distance > 0) {
              this.day = Math.floor(time_distance / 86400000)
              time_distance -= this.day * 86400000;
              this.h = Math.floor(time_distance / 3600000)
              time_distance -= this.h * 3600000;
              this.m = Math.floor(time_distance / 60000)
              time_distance -= this.m * 60000;
              this.s = Math.floor(time_distance / 1000)
              if (this.h < 10)
                this.h = "0" + this.h;
              if (this.m < 10)
                this.m = "0" + this.m;
              if (this.s < 10)
                this.s = "0" + this.s;
            } else {
              clearInterval(go);
            }
          }
          timeFunction();
          let go = setInterval(function () {
            timeFunction();
          }, 1000);
        },
  • 相关阅读:
    安装future包,django-crispy-forms
    django学习笔记(七)-----视图
    django学习笔记(六)-----模型
    django学习笔记(五)------path
    django学习笔记(四)---基本流程三(视图,模板基本使用)
    django学习笔记(三)--基本流程二---admin站点管理
    django学习笔记(二)基本流程一
    C#时间
    可空类型的DateTime转换成字符串
    asp.net mvc Razor一点小注意点
  • 原文地址:https://www.cnblogs.com/huanhuan55/p/13362776.html
Copyright © 2011-2022 走看看