Results 1 to 2 of 2

Thread: Countdown for DATE and TIME

  1. #1
    Join Date
    Oct 2012
    Location
    England
    Posts
    98
    Thanks
    27
    Thanked 2 Times in 1 Post

    Default Countdown for DATE and TIME

    Hi,

    I've got this bit of Action Script here which works out fine for DATES but I need to modify it for TIMES as well, such as exam date and times.

    Say the Exam starts at 9.00am May 2nd 2014.
    Thanks
    Code:
    //This countdown will countdown to Christmas of the current year by default. You can learn how to change this at:
    //http://mytutorialz.wordpress.com/2011/08/27/creating-a-flash-countdown-timer/
    
    //I would also like to ask that you keep the small credit in the footer of this countdown, it doesn't link back - so
    //don't worry, visitors won't leave your site for mine! Please show your support for me! :D
    
    
    //This line tells Flash to start the countdown on load:
    this.onEnterFrame = function() {
        
    //Set the variables:
    var today:Date = new Date();
    var currentYear = today.getFullYear();
    var currentTime = today.getTime();
    
    
    //Now, here is where you can set the countdown date.
    
    //The format for dates in flash are: Year, Month (0-11, 0 being January), Day.
    //To countdown to the current year, use 'CurrentYear' or for a specific year, use '2011', '2012' etc.
    var targetDate:Date = new Date(currentYear, 04, 02);
    var targetTime = targetDate.getTime();
    
    //Here's all the maths. Don't edit this unless you know what you're doing!
    var timeLeft = targetTime - currentTime;
    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_txt.text = counter;
    
    }
    
    //The end!!
    Last edited by Beverleyh; 04-29-2014 at 02:12 PM. Reason: formatting

  2. #2
    Join Date
    Oct 2012
    Location
    England
    Posts
    98
    Thanks
    27
    Thanked 2 Times in 1 Post

    Default

    Worked it out...

    HTML Code:
    var targetDate:Date =  new Date(2014,05,19,19,0,0,0);
    The Prom is on the 19th June 2014 and starts at 7pm.

    Format is Year, Month (minus 1), Date, Hour (Works in 24 hour clock so the Prom starts at 7pm = 19), Minute, Second, Millisecond

Similar Threads

  1. setting Universal Countdown to a daily countdown not a specific date.
    By droog in forum Dynamic Drive scripts help
    Replies: 10
    Last Post: 06-27-2012, 03:38 PM
  2. CountDown to Date
    By bluewalrus in forum JavaScript
    Replies: 3
    Last Post: 06-20-2011, 08:45 PM
  3. Dynamic Drive Countdown Date Modification
    By markgDR in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 04-05-2010, 05:32 AM
  4. Countdown to input time.
    By kirtangl in forum JavaScript
    Replies: 6
    Last Post: 08-18-2008, 11:37 PM
  5. Another date question (countdown)
    By Dennis_Gull in forum PHP
    Replies: 3
    Last Post: 04-28-2007, 02:27 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •