7 Replies Latest reply on Feb 18, 2012 6:54 AM by kglad

    Can't get countdown clock to show the correct time

    BigChump

      I have changed my newDate to see where the problem lies but cannot get it to match my target time to 2/22/2012 7pm

       

      this.onEnterFrame = function() {

          var today = new Date();

         

          var currentYear = today.getFullYear();

          var currentTime = today.getTime();

         

          var targetDate = new Date(2012, 2, 31, 7);

          var targetTime = targetDate.getTime();

          var timeLeft = targetTime-currentTime;

          //var timeLeft = 900000000000;

         

          var sec = Math.floor(timeLeft/1000);

          var min = Math.floor(sec/60);

          var hrs = Math.floor(min/60);

          var days = Math.floor(hrs/24);

          sec = String(sec%60);

          if (sec.length<2) {

              sec = "0"+sec;

          }

         

          min = String(min%60);

          if (min.length<2) {

              min = "0"+min;

          }

         

          hrs = String(hrs%24);

          if (hrs.length<2) {

              hrs = "0"+hrs;

          }

         

          days = String(days);

          var counter = String(days + ":" +  hrs + ":" + min + ":" + sec);

          time_days.text = days-31

          time_hrs.text = hrs

          time_mins.text = min

          time_secs.text = sec

      };