JRS: In article <11**********************@g49g2000cwa.googlegroups .com>
, dated Fri, 14 Oct 2005 17:18:19, seen in news:comp.lang.javascript,
justme <00****@gmail.com> posted :
Hi - can someone help me please?
I would like a countdown script which:
a) is presented as a form to the user
b) form has two date fields (today's date and upcoming event date)
c) results field, in which the difference calculated is displayed.
Results only need to be presented in DAYS format (i.e, don't need to
display hours, minutes, seconds etc..)
Use a method based on Zeller's Congruence or similar to convert Y M D to
a DayCount; and subtract. Or use Date Objects, subtract, divide by
864e5, and round to integer. Remember to validate the dates, if it
matters.
The second script I'm after, is a simple
calculation-of-seconds-since-birth script - also in displayed as a form
the user fills in their initial birth date/time details, results
displayed in a "You are ..... seconds old"
Cannot be done reliably. Javascript, like most OSs, has no knowledge of
Summer Time rules other than the current ones; and in most locations the
rules have changed since most people were born, or are about to change.
You'd need to know the moment of birth in UTC.
And they don't know about Leap Seconds either, so even UTC won't give
the right answer unaided.
Hoe many seconds old is a child born in Berlin on 2000-10-29 at 02:30
local time, if it's now whatever time it is at your (unspecified)
location?
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.