[Javascript] Compare two dates
Laurent Muchacho
elmuchacho at gmail.com
Fri Oct 14 09:11:50 CDT 2005
Hi Olivier,
Found below the code describing how to check 2 dates.
The Variable "now" define the present time, the only thing you need to do is
substract the date you wish to check and if the difference is a negative
value then the date happen before.
I hope this help sorry my explanation is not really clear but I guess this
is what you are looking for.
var now = new Date();
var yesterday = new Date(2005,09,13,00,00,00);
var tomorrow= new Date(2005,09,15,00,00,00);
alert('now : ' + now + '\nyesterday : ' + yesterday + '\ntomorrow : ' +
tomorrow);
alert((yesterday - now)+ '\n' + (tomorrow - now))
if((yesterday - now)<0){
alert('date tested as before now');
}
Laurent
----- Original Message -----
From: "OIivier Grossmann" <ol.grossmann at bluewin.ch>
To: <javascript at LaTech.edu>
Sent: Friday, October 14, 2005 2:05 PM
Subject: [Javascript] Compare two dates
> Hello everybody,
>
> i would like to validate/compare two dates. The first date should be
> earlier
> than the second one.
>
> Have you an idea?
>
> Greet Olivier
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
More information about the Javascript
mailing list