Use the getTime()
method. It will check the numeric value of the date and it will work for both the greater than/less than checks as well as the equals checks.
EDIT:
if (d1.getTime() === d2.getTime())
More Related Contents:
- Checking if two Dates have the same date info
- JavaScript Date Comparisons Don’t Equal [duplicate]
- How to calculate number of days between two dates?
- Get week of year in JavaScript like in PHP
- How do you display JavaScript datetime in 12 hour AM/PM format?
- JavaScript seconds to time string with format hh:mm:ss
- Get the time difference between two datetimes
- Comparing date part only without comparing time in JavaScript
- Get String in YYYYMMDD format from JS date object?
- new Date() works differently in Chrome and Firefox
- how to parse a “dd/mm/yyyy” or “dd-mm-yyyy” or “dd-mmm-yyyy” formatted date string using JavaScript or jQuery [duplicate]
- Parsing a string to a date in JavaScript
- new Date() is working in Chrome but not Firefox
- How to format a UTC date as a `YYYY-MM-DD hh:mm:ss` string using NodeJS?
- Check if one date is between two dates
- Javascript library for human-friendly relative date formatting [closed]
- Moment.js: Date between dates
- Date.getDay() javascript returns wrong day
- Date difference in Javascript (ignoring time of day)
- Javascript equivalent of php’s strtotime()?
- Inserting and Querying Date with MongoDB and Nodejs
- how to compare two string dates in javascript?
- how can I convert day of year to date in javascript?
- Moment.js – How To Detect Daylight Savings Time And Add One Day
- How to check if a string is a legal “dd/mm/yyyy” date?
- Getting the date of next Monday
- Java date format to JavaScript date format
- Generate random date between two dates and times in Javascript
- Convert iso timestamp to date format with Javascript?
- How to convert Moment.js date to users local timezone?