# How to check if two dates are the same day in JavaScript

> Learn how to check if two dates fall on the same day in JavaScript by comparing their getFullYear(), getMonth(), and getDate() values in a helper function.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2019-10-12 | Topics: [JavaScript](https://flaviocopes.com/tags/js/) | Canonical: https://flaviocopes.com/how-to-check-dates-same-day-javascript/

How do you detect if a date object instance in [JavaScript](https://flaviocopes.com/javascript/) refers to the same day of another date object?

JavaScript does not provide this functionality in its standard library, but you can implement it using the methods

- `getDate()` returns the day
- `getMonth()` returns the month
- `getFullYear()` returns the 4-digits year

This is a simple function you can copy/paste to do the check:

```js
const datesAreOnSameDay = (first, second) =>
    first.getFullYear() === second.getFullYear() &&
    first.getMonth() === second.getMonth() &&
    first.getDate() === second.getDate();
```

Example usage:

```js
datesAreOnSameDay(new Date(), new Date()) //true
```
