Search the archives!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Javascript] Compare two dates
- From: elmuchacho at gmail.com (Laurent Muchacho)
- Subject: [Javascript] Compare two dates
- Date: Fri Oct 14 09:12:01 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@xxxxxxxxxx>
To: <javascript@xxxxxxxxxx>
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@xxxxxxxxxx
> https://lists.LaTech.edu/mailman/listinfo/javascript
- Follow-Ups:
- [Javascript] Compare two dates
- From: OIivier Grossmann
- [Javascript] Compare two dates
- References:
- [Javascript] Compare two dates
- From: OIivier Grossmann
- [Javascript] Compare two dates
- Prev by Date: [Javascript] Compare two dates
- Next by Date: [Javascript] Compare two dates
- Previous by thread: [Javascript] Compare two dates
- Next by thread: [Javascript] Compare two dates
- Index(es):