i have a date formated as 3/13/2022 05:44 PM
how to compare this date with the other dates which is formated in this manner and checks whether it is in past or future
Ohkay, so you need to compare the two dates and find which is latest, that is past or future..
So, you can just convert the dates to milliseconds using the Date.parse() function. This will parses a date string and returns the number of milliseconds since midnight January 1, 1970.
And then compare the two numbers accordingly.. For example:
<p id="demo"></p>
<script>
let ms = Date.parse("3/13/2022 05:47 PM");
let ns = Date.parse("3/13/2022 04:47 AM");
if(ms > ns){
document.getElementById("demo").innerHTML = "3/13/2022 05:47 PM is Future";
}else{
document.getElementById("demo").innerHTML = "3/13/2022 04:47 AM is Future";
}