Calculate difference in dates

D

Dr John Stockton

JRS: In article <[email protected]>, dated
Tue, 7 Sep 2004 03:53:05, seen in Otter
I've looked high and low for a javascript counter which can break down
to years/month/days since an event happened but I have yet to find
one. I am assuming now that it can't be done otherwise I'm sure I
would have come across one by now. Found lots of unanswered requests
for the same by others.

Counting in Y M D is not all that meaningful, since months (and years,
and days) vary in length.

By using the newsgroup FAQ, you should have found one which counts in
days and hh:mm:ss until Xmas noon (js-date2.htm#RC); you should be able
to modify that to count up.

Likewise, you could have found js-date1.htm#DYMD, which gives the
difference between two dates in Y M D.

Note that, since months differ in length, with two dates D1 D2, the YMD
that D2 is after D1 does not necessarily match the YMD that D1 is before
D2, on reasonable definitions.
 
J

John G Harris

If "theHour" is 0, then it is "12" am, no?
Mick
<snip>

Or 12 pm if your reference point is the previous noon instead of the
next noon.

There is also the problem of 12 noon, which is neither before (ante) nor
after (post) noon.

Altogether, the 24 hour clock as the railways call it is a lot easier to
code.

John
 
L

Lasse Reichstein Nielsen

Mick White said:
Lasse Reichstein Nielsen wrote:

Yes, you could, but it would be wrong. What if theHour is 0 (zero)?

Arh, bugger. I always forget that %12 can give results that are not
between 0 and 11. May whoever made that decission be forced to watch
Barney for 24 hours a day until he repents!

/L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top