Files
30-seconds-of-code/snippets/isSameDate.md
2022-05-02 18:51:12 +03:00

546 B

title, tags, expertise, cover, firstSeen, lastUpdated
title tags expertise cover firstSeen lastUpdated
Date is same as another date date beginner blog_images/pineapple-at-work.jpg 2018-09-29T13:58:38+03:00 2020-11-03T22:11:18+02:00

Checks if a date is the same as another date.

  • Use Date.prototype.toISOString() and strict equality checking (===) to check if the first date is the same as the second one.
const isSameDate = (dateA, dateB) =>
  dateA.toISOString() === dateB.toISOString();
isSameDate(new Date(2010, 10, 20), new Date(2010, 10, 20)); // true