Tutorialspoint

Comparing Two Dates using Javascript Program

<!DOCTYPE html>
<html>
<body>
<script>
 var date1, date2;
 date1 = new Date();
 document.write(date1);

 date2 = new Date( "Dec 15, 2014 21:20:15" );
 document.write("<br>"+date2);
 if (date1 > date2) {
 document.write("<br>Date1 is the recent date.");
 } else {
 document.write("<br>Date 2 is the recent date.");
 }
</script>
</body>
</html>

Advertisements
Loading...