<bdo id='pCvT4'></bdo><ul id='pCvT4'></ul>
    1. <small id='pCvT4'></small><noframes id='pCvT4'>

    2. <tfoot id='pCvT4'></tfoot>

      1. <i id='pCvT4'><tr id='pCvT4'><dt id='pCvT4'><q id='pCvT4'><span id='pCvT4'><b id='pCvT4'><form id='pCvT4'><ins id='pCvT4'></ins><ul id='pCvT4'></ul><sub id='pCvT4'></sub></form><legend id='pCvT4'></legend><bdo id='pCvT4'><pre id='pCvT4'><center id='pCvT4'></center></pre></bdo></b><th id='pCvT4'></th></span></q></dt></tr></i><div id='pCvT4'><tfoot id='pCvT4'></tfoot><dl id='pCvT4'><fieldset id='pCvT4'></fieldset></dl></div>
      2. <legend id='pCvT4'><style id='pCvT4'><dir id='pCvT4'><q id='pCvT4'></q></dir></style></legend>

        以天、小时、分钟、秒为单位的 Javasacript 倒数计时器

        Javasacript Countdown timer in Days, Hours, Minute, Seconds(以天、小时、分钟、秒为单位的 Javasacript 倒数计时器)

          <legend id='8icN0'><style id='8icN0'><dir id='8icN0'><q id='8icN0'></q></dir></style></legend>
          • <i id='8icN0'><tr id='8icN0'><dt id='8icN0'><q id='8icN0'><span id='8icN0'><b id='8icN0'><form id='8icN0'><ins id='8icN0'></ins><ul id='8icN0'></ul><sub id='8icN0'></sub></form><legend id='8icN0'></legend><bdo id='8icN0'><pre id='8icN0'><center id='8icN0'></center></pre></bdo></b><th id='8icN0'></th></span></q></dt></tr></i><div id='8icN0'><tfoot id='8icN0'></tfoot><dl id='8icN0'><fieldset id='8icN0'></fieldset></dl></div>

            <small id='8icN0'></small><noframes id='8icN0'>

            <tfoot id='8icN0'></tfoot>

                  <bdo id='8icN0'></bdo><ul id='8icN0'></ul>
                    <tbody id='8icN0'></tbody>
                • 本文介绍了以天、小时、分钟、秒为单位的 Javasacript 倒数计时器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试创建一个基于时间的倒计时时钟.它不是基于 current_dates.将被拉取的初始时间将来自一个单独的 php 文件.这将用于基于浏览器的游戏.当有人单击按钮启动此脚本时.它将检查是否满足某些要求,如果满足则此脚本将启动.根据对象的级别,它将拉动该进程级别的初始计时器.希望这是有道理的.无论如何,我基于我提供的第一个代码编写了计时器脚本.

                  I'm trying to create a time-based count down clock. It is not based upon current_dates. The initial time that will be pulled will be from a separate php file. This will be for a browser based-game. When someone clicks the button to initiate this script. it will check if certain requirements are met and if so then this script will initiate. Based upon the level of the object it will pull the initial timer for that proceeding level. Hope that makes sense. Anyhow I based the timer script off of the first code I provide.

                  这个脚本只占分秒.我修改了它以包括天数和小时数.在这个过程中的某个地方我搞砸了,脚本甚至根本不起作用.我也不太确定这是否是计算此值的最佳方法.因此,如果您有更简洁的方法来执行此操作,请分享.提前致谢.

                  This script only accounts for minutes and seconds. I modified it to include days and hours as well. Somewhere in the process I have messed up and the script doesn't even work at all. I'm also not quite sure if this would be the best method to calculate this. So, if you have a cleaner method at doing this please share. Thank you in advance.

                  此脚本基于我看到的分钟/秒脚本.原文出处:

                  This script is based off of a minutes / seconds script I saw. Here's the original source:

                  <span id="countdown" class="timer"></span>
                  <script>
                     var seconds = 60;
                     function secondPassed() {
                     var minutes = Math.round((seconds - 30)/60);
                     var remainingSeconds = seconds % 60;
                     if (remainingSeconds < 10) {
                        remainingSeconds = "0" + remainingSeconds; 
                     }
                     document.getElementById('countdown').innerHTML = minutes + ":" + remainingSeconds;
                     if (seconds == 0) {
                      clearInterval(countdownTimer);
                      document.getElementById('countdown').innerHTML = "Buzz Buzz";
                     } else {
                      seconds--;
                     }
                     }
                     var countdownTimer = setInterval('secondPassed()', 1000);
                  </script>
                  

                  这是我试图包含天、小时、分钟和秒的修改后的脚本.

                  Here is the modified script that I am trying to include days, hours, minutes and seconds.

                  <span id="countdown"></span>
                  <script>
                       var current_level = 93578;
                  
                       function timer() {
                  
                          var days = Math.round(current_level/86400);
                          var remainingDays = Math.round(current_level - (days * 86400));
                  
                          if (days <= 0){
                               days = current_level;
                          }
                  
                          var hours = Math.round(remainingDays/3600);
                          var remainingHours = Math.round(remainingDays - (hours * 3600));
                  
                          if (hours >= 24){
                               hours = 23;
                          }
                  
                          var minutes = Math.round(remainingHours/60);
                          var remainingMinutes = Math.round(remainingHours - (minutes * 60));
                  
                          if (minutes >= 60) {
                               minutes = 59;
                          }
                  
                          var seconds = Math.round(remainingMinutes/60);
                  
                          document.getElementById('countdown').innerHTML = days + ":" + hours ":" + minutes + ":" + seconds;
                  
                          if (seconds == 0) {
                               clearInterval(countdownTimer);
                               document.getElementById('countdown').innerHTML = "Completed";
                          }
                       }
                       var countdownTimer = setInterval('timer()', 1000);
                  </script>
                  

                  推荐答案

                  我终于回过头来看这个并重新编写代码,这就像一个魅力.

                  I finally got back to looking at this and re-wrote the code and this works like a charm.

                  var upgradeTime = 172801;
                  var seconds = upgradeTime;
                  function timer() {
                    var days        = Math.floor(seconds/24/60/60);
                    var hoursLeft   = Math.floor((seconds) - (days*86400));
                    var hours       = Math.floor(hoursLeft/3600);
                    var minutesLeft = Math.floor((hoursLeft) - (hours*3600));
                    var minutes     = Math.floor(minutesLeft/60);
                    var remainingSeconds = seconds % 60;
                    function pad(n) {
                      return (n < 10 ? "0" + n : n);
                    }
                    document.getElementById('countdown').innerHTML = pad(days) + ":" + pad(hours) + ":" + pad(minutes) + ":" + pad(remainingSeconds);
                    if (seconds == 0) {
                      clearInterval(countdownTimer);
                      document.getElementById('countdown').innerHTML = "Completed";
                    } else {
                      seconds--;
                    }
                  }
                  var countdownTimer = setInterval('timer()', 1000);

                  <span id="countdown" class="timer"></span>

                  这篇关于以天、小时、分钟、秒为单位的 Javasacript 倒数计时器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                  • <i id='p1fxx'><tr id='p1fxx'><dt id='p1fxx'><q id='p1fxx'><span id='p1fxx'><b id='p1fxx'><form id='p1fxx'><ins id='p1fxx'></ins><ul id='p1fxx'></ul><sub id='p1fxx'></sub></form><legend id='p1fxx'></legend><bdo id='p1fxx'><pre id='p1fxx'><center id='p1fxx'></center></pre></bdo></b><th id='p1fxx'></th></span></q></dt></tr></i><div id='p1fxx'><tfoot id='p1fxx'></tfoot><dl id='p1fxx'><fieldset id='p1fxx'></fieldset></dl></div>

                      <legend id='p1fxx'><style id='p1fxx'><dir id='p1fxx'><q id='p1fxx'></q></dir></style></legend>

                        <bdo id='p1fxx'></bdo><ul id='p1fxx'></ul>

                            <tbody id='p1fxx'></tbody>

                            <small id='p1fxx'></small><noframes id='p1fxx'>

                            <tfoot id='p1fxx'></tfoot>