JRS: In article <vj************@corp.supernews.com>, seen in
news:comp.lang.javascript, Matt Stanley <ma**@lebois.com> posted at Sat,
16 Aug 2003 18:30:55 :-
I am using the countdown script developed by Chris Nott on his
website(http://www.dithered.com/javascript/c.../example.html).
The script is not all it could be.
It makes no adjustment for Summer Time, so that at present, 22:39:+, it
says ... 02 hours 20 minutes ... away.
It has
var days = parseInt(difference / 86400000) + '';
where
var days = Math.floor(difference / 86400000) + '';
is more direct and faster.
It has a fixed timeout of nominally 1000 ms, so that, because of delays,
it does not show every second (it misses about 1 in 20 in Win98, perhaps
1 in 100 in WinNT+).
The graphics are indexed by the result of parseInt on a character, where
they could be indexed by the character, or by +character.
Date fields are handled as strings; numbers seem simpler and probably
faster.
BTW, the following gives me a date-time difference in days, hh:mm:ss :
Diff = new Date(2010, 11, 25) - new Date()
X = Math.floor(Diff/864e5) + ' days, ' +
new Date(Diff%864e5).toString().match(/\S{8}/)
but I've not checked its efficiency. It will fail anywhere that
toString() does not give 24-h hh:mm:ss .
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.