AmigaActive (1360/2347)

From:Joris Kempen
Date:18 Mar 2001 at 07:41:55
Subject:Javascript date problem

Hello,

For my website i created a small function in javascript. This function needs
a date as input and will give you back the number of days till this given
date. Here is the code

<SCRIPT type="text/javascript" language="JavaScript">
<!-- hier begint het javascript
function hoelang(dag,maand,jaar)
{
vandaag = new Date();
toekomst = new Date(jaar,maand,dag);

msday = 24 * 60 * 60 * 1000;
verschil = (toekomst.getTime() - vandaag.getTime() ) / msday;
verschil = Math.round(verschil)+1;
return verschil;
}
// hier eindigt het script -->
</SCRIPT>

and this is the call to the script.
<script type="text/javascript">document.write(hoelang(20,7,2001))</script>

Now my problem: it does work on Aweb, not on Ibrowse or Voyager, but i don't
have a problem with that. My problem is that it doesn't work correctly on
IE and Netscape....

Both browser give back the number of days but the gave me 30 days extra!!!
and that's what i really don't want :(
Anyone see the problem in my script? The idea that gives back 30 days to
much makes me think i has something to with a 'month-problem' cos a month
has 30 or 31 days:) (even 28 or 29 sometimes).

Suggestions please...

Kind regards
Joris

------------------------ Yahoo! Groups Sponsor ---------------------~-~>
Make good on the promise you made at graduation to keep
in touch. Classmates.com has over 14 million registered
high school alumni--chances are you'll find your friends!
http://us.click.yahoo.com/l3joGB/DMUCAA/4ihDAA/d8AVlB/TM
---------------------------------------------------------------------_->

Quote carefully and read all ADMIN:README mails

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/