0

Need to compare two dates in the following formats

a) Date1 - 01 Feb 2019 and second is

b) Date2 - 2/3/2017

I need to ensure that they cater to invalid dates and Date1 > date 2

function ValidateDates()
{

    var Date1 =" 01 Feb 2019";
    var Date2 ="2/3/2017";
    if(new Date(Date1) > new Date(Date2))
   {
     console.log("Date1 is greater");
   }

}  

I am not looking for a script library like moment . Just want a JavaScript solution.

2

1 Answer 1

0
Date.parse(endDate) > Date.parse(startDate)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.