Jump to content

DesignMonkey

Members
  • Posts

    4
  • Joined

  • Last visited

Posts posted by DesignMonkey

  1. Ladies and Gentleman, I have solved my own issue.

    Please reference this code below if you're ever trying to count up from one date to another. 
     

    <script>
    // Set the date we're counting down to
    var countStartDate = new Date("Aug 21, 2018").getTime();
    var countYearStart = new Date ("Jan 1, 2019").getTime();
    
    
    // Update the count down every 1 second
    var x = setInterval(function() {
    
      // Get todays date and time
      var now = new Date().getTime();
    
      // Find the distance between now and the count down date
      var distance = now - countYearStart + countYearStart - countStartDate ;
    
      // 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);
    
      // Display the result in the element with id="demo"
      document.getElementById("demo").innerHTML = days + "d " + hours + "h "
      + minutes + "m " + seconds + "s ";
    
      // If the count down is finished, write some text 
      if (distance < 0) {
        clearInterval(x);
        document.getElementById("demo").innerHTML = "EXPIRED";
      }
    }, 1000);
    </script>

    Cheers

  2. Thank you everyone for all of your help, but this doesn't quite solve my issue. I was a little vague about what I wanted this timer to accomplish I suppose.

    On my companies website I show the years of experience with a big heading that says "29". Underneath that heading I have some text that says "Years of experience and counting".

    I'm trying to get the timer to count up from Aug 21 of 2018 to Aug 21 of 2019 to show that with every passing day our company is gaining experience and growing. 

    So it would look something like:

    29

    Years of experience and counting

    Days, Hours, Minutes, Seconds <- and then the program expires once the timer hits 365 Days.

  3. Hey everyone! I could really use some help making my "countdown" timer count up by days, minutes, seconds. How do I modify the code below to accomplish this! Thanks again! 

     

    <!-- Display the countdown timer in an element -->
    <p id="demo"></p>
    
    <script>
    // Set the date we're counting down to
    var countDownDate = new Date("Jan 5, 2021 15:37:25").getTime();
    
    // Update the count down every 1 second
    var x = setInterval(function() {
    
      // Get todays 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);
    
      // Display the result in the element with id="demo"
      document.getElementById("demo").innerHTML = days + "d " + hours + "h "
      + minutes + "m " + seconds + "s ";
    
      // If the count down is finished, write some text 
      if (distance < 0) {
        clearInterval(x);
        document.getElementById("demo").innerHTML = "EXPIRED";
      }
    }, 1000);
    </script>

     

×
×
  • Create New...