Files
30-seconds-of-code/snippets/isSameDate.md
Isabelle Viktoria Maciohsek 05e3f6dc07 Format snippets
2020-11-03 22:11:18 +02:00

400 B

title, tags
title tags
isSameDate date,beginner

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