/    Sign up×
Community /Pin to ProfileBookmark

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 ([URL=”http://www.dynamicdrive.com/dynamicindex6/dhtmlcount.htm”]here[/URL])
and the bold italic code is from the Dynamic collapse at dynamicdrive ([URL=”http://www.dynamicdrive.com/dynamicindex17/animatedcollapse.htm”]here[/URL])

[CODE]
<script>
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;

[B]var futuredate=new cdtime(“build”+src+”Counter”, DATE);
futuredate.displaycountdown(“days”, formatresults);
[/B]

document.getElementById(“build”+src+”TEXT”).innerHTML = text;
[B][I]animatedcollapse.show(“build”+src);[/I][/B]
}
</script>

<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>
</div>
[/CODE]

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 ??

edit:
ok it just seems to display the finish message from DD’s countdown script…

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@justinbarneskinSep 27.2009 — "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.
×

Success!

Help @vinny619 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...