Tuesday, March 18, 2014

comparing two dates using javascript

one way:

<!DOCTYPE html>
<html>
<body>

<script type="text/javascript"language="javascript">

   function CompareDate() {
       //Note: 00 is month i.e. January
       var dateOne = new Date(2011, 11, 15); //Year, Month, Date
       var dateTwo = new Date(2011, 11, 05); //Year, Month, Date
       if (dateOne > dateTwo) {
            alert("Date One is greather then Date Two.");
        }else {
            alert("Date Two is greather then Date One.");
        }
    }

    CompareDate();
</script>

</body>
</html>

No comments:

Post a Comment