User Id :    Password :      New Member   Forgot Password  
 
Compare two dates in java script
Description The Date object is also used to compare two dates.   No. of Views     1932
  Rating     4
Author Najmul Hoda   Posted On     01 Feb 2010
Tags Java Script    

Sample Code   Download Code

Introduction

I have written this code on ‘Compare Two Dates’. By using JavaScript, The Date object is also used to compare two dates.
The following example compares today's date with the 02nd February 2010:

 var yourDate=new Date();
 yourDate.setFullYear(2010,02,02);
 var toDay = new Date();

 if (yourDate>toDay)
   {
   alert("Today is before 2nd February 2010");
   }
 else
   {
   alert("Today is after 2nd February 2010");
   }

About Author

About Author He is a team lead, having 8+ years of experience. He loves writing technical article for .Net developers. Najmul Hoda
No Photo
 
Country United States
Company BirlaSoft
Home Page http://www.magixchat.com

Rate this article

Rating options from poor, fair, good, very good to excelent.  
 

Comments

   
Write your comment here.
Comment
Verification Code