Still, if you want to compare those operators which I told you can not use. In the above example, first we are constructing the dates with delimiter -then we are comparing the first date with second date, if both dates are equal it returns true else it returns false if it is not equal.. Second way using toDateString() method. Given a Date instance, we can use the getDate(), getMonth() and getFullYear() methods, which return the day, month and year of a date, and compare them to today, which can be retrieved using new Date(). In Javascript comparing date is quite simple. Thus, we can compare dates in many possible ways. . JavaScript's Date Object. Here, with the help of those methods, we will learn to compare dates. console . The dates can belong to any frame i.e past, present and future. Use Date() function to create an object in JavaScript with current date and time. Opera … 2. var today = new Date(); We can also change or set the format through JavaScript code. "); } In some cases where the Date object is dynamically created in javascript, if you keep printing the Date.getTime (), you'll see the milliseconds changing, which will prevent the equality of both dates. The following example code checks whether given date is greater than current date or today using with new Date() in JavaScript. Create a Date object and alert the current date and time. For a human being, of course, that’s such and easy task that you generally don’t even need to think about it, and for the most part, it’s not that much more difficult for a computer to do. See the Pen JavaScript - Comparison between two dates-date-ex- 5 by w3resource (@w3resource) on CodePen. alert ("Date … s such and easy task that you generally don’t even need to think about it The getTime () method. Date/time is a complex concept.