/    Sign up×
Community /Pin to ProfileBookmark

Daily counter

Hey Folks-
I am trying to find some javascript that will allow me to automatically add one digit a day to a counter. I’m tracking how many days Jose Padilla has been kept in US custody without a trial but I sometimes forget to change the day. I know there must be some simple piece of code but I’m a writer (I know? not a coder.

Check out: [url]http://nakedzoo.blogspot.com/[/url]

See the 1244 on the right? I want that to go up by a factor of one everyday.

Thanks very much.

Adam

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@UltimaterSep 30.2005 — <i>
</i>&lt;head&gt;
&lt;script type="text/javascript"&gt;
function getD(){
var then=new Date(1020615616703);//Sun, 05 May 2002 16:20:16 GMT
var now=new Date();
var d=now.getTime()-then.getTime();
d=Math.floor(d/1000/60/60/24);
return d;
}
&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;

It's been &lt;script type="text/javascript"&gt;
document.write(getD())
&lt;/script&gt; days since whatever.
&lt;/body&gt;
Copy linkTweet thisAlerts:
@baijieSep 30.2005 — thanks
Copy linkTweet thisAlerts:
@MjhLkwdSep 30.2005 — [CODE]<HTML>
<Head>
<Script type="text/javascript">

var baseDate = "2002 January 27 00:00";
var message = "since Jose Padilla was imprisoned.";
var refDate = new Date(baseDate);

function dispCounter(){

var currDate = new Date();
var elapsedTime = currDate-refDate;
var nDays = parseInt(elapsedTime/86400000);
document.getElementById('elapsed').innerHTML = "It's been " +nDays +" days "+message;
}

window.onload=dispCounter;

</Script>
</Head>
<Body>
<Div id='elapsed' style='border:solid black 1px;width:435px;height:12px;font-size:14pt;text-align:center;padding:3px;background-color:lightyellow;color:darkblue'>
</Div>
</Body>
</HTML>[/CODE]
×

Success!

Help @Adrey 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.1,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

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