[Javascript] Compare two dates

OIivier Grossmann ol.grossmann at bluewin.ch
Fri Oct 14 10:19:48 CDT 2005


Hello Laurent,

thanks for your explanation.
I have implemented your code example into my source successfully.

Thanks.

Greet Olivier

>-- Original-Nachricht --
>From: "Laurent Muchacho" <elmuchacho at gmail.com>
>To: "[JavaScript List]" <javascript at LaTech.edu>
>Subject: Re: [Javascript] Compare two dates
>Date: Fri, 14 Oct 2005 15:11:50 +0100
>Reply-To: "[JavaScript List]" <javascript at LaTech.edu>
>
>
>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 
>
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>https://lists.LaTech.edu/mailman/listinfo/javascript




More information about the Javascript mailing list