7 March 2022

How to compare two different date format in JQuery

 

<!DOCTYPE html>
<html>
  <head>
    <script src="js/jquery-3.6.0.js"></script>
    <script>
      $(document).ready(function () {
        var x =  new Date();
        var Date_y = "13-02-2024";
        split_y = Date_y.split('-');
        var y = new Date(split_y[2]+'-'+split_y[1]+'-'+split_y[0]);  
        if(new Date(x) <= new Date(y))
        {
            alert('y');
        }
        else{
            alert('x');
        }
      });
    </script>
  </head>
  <body></body>
</html>


 Github Link: https://github.com/adi501/JQuery-Examples



No comments:

Post a Comment