Jump to content

Countdown Timer not displaying correctly on mobile - NAND NANM NANH NANS

Recommended Posts

Posted

Site URL: http://savingmyanmar.com

Put together a teaser landing page for our site launch with a countdown timer. Everything seems to function properly when viewing the desktop version AND when testing the mobile version on Desktop, but once I pull up the page on my actual mobile device, the numbers all display NAND NANH NANM NANS.

I understand that that stands for Not Available Number Day, .... Hours..... Minutes.... Seconds....

Here is my code. Can anyone help?

Quote

<html>
<h2>
<head>
<style>
body {
    text-align: center;
}
</style>
</head>
<body>
<p id="demo"></p>
  
<script>
// Set the date we're counting down to
var countDownDate = new Date("05/01/2021 24:00:00").getTime();

// Update the count down every 1 second
var x = setInterval(function() {

  // Get today's date and time
  var now = new Date().getTime();    
    
  // Find the distance between now and the count down date
  var distance = countDownDate - now;
    
  // Time calculations for days, hours, minutes and seconds
  var days = Math.floor(distance / (1000 * 60 * 60 * 24));
  var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
  var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
  var seconds = Math.floor((distance % (1000 * 60)) / 1000);
    
  // Output the result in an element with id="demo"
  document.getElementById("demo").innerHTML = days + "d " + hours + "h "
  + minutes + "m " + seconds + "s ";
    
  // If the count down is over, write some text 
  if (distance < 0) {
    clearInterval(x);
    document.getElementById("demo").innerHTML = "IT'S TIME!";
  }
}, 1000);
</script>
</body>
</h2>
</html>

 

IMG_0FB1DD226210-1.jpeg

  • Replies 3
  • Views 1.3k
  • Created
  • Last Reply

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.