Java脚本代码在Internet Explorer中无法正常运行,而在Google Chrome中可以正常运行

这段代码在Google Chrome浏览器中运行正常,而在Internet Explorer中则无法运行。

它是用JavaScript编写并与HTML一起使用的计时器代码。

如果有人可以帮助您同时控制chrome和Internet Explorer的屏幕快照,请附加屏幕截图。他们没有显示错误。

function makeTimer() {

  //		var endTime = new Date("29 April 2018 9:56:00 GMT+01:00");	
  var endTime = new Date("19 May 2020 17:30:00 GMT+05:00");
  endTime = (Date.parse(endTime) / 1000);

  var now = new Date();
  now = (Date.parse(now) / 1000);

  var timeLeft = endTime - now;

  var days = Math.floor(timeLeft / 86400);
  var hours = Math.floor((timeLeft - (days * 86400)) / 3600);
  var minutes = Math.floor((timeLeft - (days * 86400) - (hours * 3600)) / 60);
  var seconds = Math.floor((timeLeft - (days * 86400) - (hours * 3600) - (minutes * 60)));

  if (hours < "10") {
    hours = "0" + hours;
  }
  if (minutes < "10") {
    minutes = "0" + minutes;
  }
  if (seconds < "10") {
    seconds = "0" + seconds;
  }

  $("#days").html(days + "<span>Days</span>");
  $("#hours").html(hours + "<span>Hours</span>");
  $("#minutes").html(minutes + "<span>Minutes</span>");
  $("#seconds").html(seconds + "<span>Seconds</span>");

}

setInterval(function() {
  makeTimer();
}, 1000);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="d-inline-block py-3" id="timer">
  <div class="d-inline-block px-3" id="days" style="border-right:1px solid white; color:#44cbe1"></div>
  <div class="d-inline-block px-3" id="hours" style="border-right:1px solid white; color:#44cbe1"></div>
  <div class="d-inline-block px-3" id="minutes" style="border-right:1px solid white; color:#44cbe1"></div>
  <div class="d-inline-block px-3" id="seconds" style="color:#44cbe1"></div>
</div>

Console Screenshot

Internet Explorer Screenshot

评论