Results 1 to 2 of 2

Thread: need help with adding time to date

  1. #1
    Join Date
    Feb 2007

    need help with adding time to date

    hi, sorry this post is so long, lol

    I have a download page, which I want users to wait a certain amount of time before they can download, waiting time depends on the queue wait time, say each user has to wait 30 seconds, and there are 10 users waiting, then the last user will have to wait 3 minutes.

    I have this javascript function to do the math, the bold code is part of the Dynamic countdown script at dynamicdrive (here)
    and the bold italic code is from the Dynamic collapse at dynamicdrive (here)

    function build(src, text, sec) {
    var d = new Date();
    var L = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
    var F = L[d.getMonth()];
    var P = new Array("01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31");
    var j = P[d.getDate()];
    var y = d.getFullYear();
    var H = d.getHours();
    var i = d.getMinutes();
    var s = d.getSeconds() + sec;
    var DATE = F+" "+j+", "+y+" "+H+":"+i+":"+s;
    var futuredate=new cdtime("build"+src+"Counter", DATE);
    futuredate.displaycountdown("days", formatresults);
    document.getElementById("build"+src+"TEXT").innerHTML = text;
    <img src="images/download.png" onclick="build('1', 'Mozilla Firefox', '30');" />
    <div id="build1" style="width:400px; background: url('images/modalBG.png'); display:none; padding:2px 5px;">
    <span style='float:right; border:0; background:transparent; width:150px;' id='build1Counter'></span>
    <div id="build1TEXT"></div>
    when the user clicks the download image the timer slides up at the bottom of the page, with the name of the download as the "build1TEXT" and the countdown in "build1Counter", but for some reason the counter says undefined if the "secs" go over 60... the problem is obviously in my build function at this line "var s = d.getSeconds() + sec;", I thought if the seconds went into minutes it would add one to the minutes but it doesn't seem to, is there anyway of doing this, seconds to minutes, minutes to hours and hours to days, as I have another use for it if anyone can sort the problem out.

    thank you in advance

    ok it just seems to display the finish message from DD's countdown script...
    Last edited by vinny619; 09-26-2009 at 12:30 AM. Reason: update

  2. #2
    Join Date
    Oct 2006
    "say each user has to wait 30 seconds, and there are 10 users waiting, then the last user will have to wait 3 minutes."

    Sorry, I can't help. Either my math or intuition is failing me. I extrapolate and see that any attempt to write code will ultimately fail. Aside from purples, blues and red, I see a candy bar wrapper that reads "5minute wait." It's dancing in front of my eyes with silly white cartoon mittens.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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