/    Sign up×
Community /Pin to ProfileBookmark

Counting Function

I have a function that will countdown from todays date to a specified date. However I was wandering if anybody had any code that would count from todays date. I want to know how long my site has been up for?? Can I manipulate my existing code?

[CODE]
<script type=”text/JavaScript”>

window.resizeTo(500,400)

var theDate,output,targetDay;
window.onload=targetdate;
function targetdate()
{
theDate=’October 1, 2005′;
targetDay=new Date(theDate);
window.setInterval(‘countDownDays()’,1000);
}
function countDownDays()
{
output=”;
dateNow=new Date();
amount=targetDay.getTime()-dateNow.getTime();
if(amount<0) output+=’It Has Arrived’;
else
{

var days=hours=mins=secs=0;
var amount=Math.floor(amount/1000);
var days=Math.floor(amount/86400);
amount=amount%86400;
var hours=Math.floor(amount/3600);
amount=amount%3600;
var mins=Math.floor(amount/60);
amount=amount%60;
var secs=Math.floor(amount);
output+=’There are only <br /><br />’;
if(days!=0) output+=days+” day”+((days!=1)?”s”:””)+”, <br /><br /> “;
if(days!=0||hours!=0) output+=hours+” hour”+((hours!=1)?”s”:””)+”, <br /><br />”;
if(days!=0||hours!=0||mins!=0) output+=mins +” minute”+((mins!=1)?”s”:””)+” and <br /><br />”;
output+=secs+” second”+((secs!=1)?”s”:””)+” left <br /><br /> until we are going back to uni <br /><br />Great!! “;
}

document.getElementById(‘countdown’).innerHTML=output;
}

</script>[/CODE]

Thanks for your help

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @andyb7901 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 5.20,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...