Jump to content

qusi

Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by qusi

  1. Perfect thaks! I must have been blind in one eye.
  2. Hi JavaScript cracks! I fount that howto and built a countup out of it. https://www.w3schools.com/howto/howto_js_countdown.asp This works well, the only thing I struggle is to include weeks. I can calculate the weeks: var weeks = Math.floor(distance / (1000 * 60 * 60 * 24 * 7)); Bud I can not substract the remaining days, similar to hours, minutes and seconds: var days = Math.floor(distance % (1000 * 60 * 60 * 24 * 7)) / (1000 * 60 * 60 * 24)); Where ist the problem? <strong>countup3:</strong> <p id="countup3"></p> <script> // Set the date we're counting up from var countUpDate3 = new Date("Mar 16, 2020 00: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 up date var distance = now - countUpDate3; // Time calculations for weeks, days, hours, minutes and seconds var weeks = Math.floor(distance / (1000 * 60 * 60 * 24 * 7)); var days = Math.floor(distance % (1000 * 60 * 60 * 24 * 7)) / (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="countup3" document.getElementById("countup3").innerHTML = weeks + " w " + days + " d " + hours + " h " + minutes + " m " + seconds " s "; }, 1000); </script>
×
×
  • Create New...