User Id :    Password :      New Member   Forgot Password  
How to compare 2 dates in javascript
Description how to compare 2 dates in javascript   No. of Views     2946
  Rating     0
Author Najmul Hoda   Posted On     21 Aug 2011
Tags Java Script    

Sample Code   Download Code


function CompareDate(txtfrom, txtto) {
    var From = txtfrom.value;
    var To = txtto.value;
    var strSplitFrom = From.split('/')
    var myDateFrom = new Date();
    myDateFrom.setFullYear(strSplitFrom[2], strSplitFrom[1] - 1, strSplitFrom[0]);

    var strSplitTo = To.split('/')
    myDateTo = new Date();
    myDateTo.setFullYear(strSplitTo[2], strSplitTo[1] - 1, strSplitTo[0]);

    if (myDateFrom > myDateTo) {

        alert("Start date can not greater than End date.");

        return false;
    else {
        return true;



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

Rate this article

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


Posted By Annonymous on 02 Sep 2011 at 10:23 PM
My hat is off to your astute cmmanod over this topic-bravo!
Write your comment here.
Verification Code