How to check if date is today in JavaScript

Checking if a date represents today is crucial for filtering real-time data, highlighting current records, and implementing time-sensitive UI features. As the creator of CoreUI with over 25 years of development experience, I’ve built this functionality into dashboard components, activity feeds, and data filtering systems countless times. The most reliable approach is comparing toDateString() values which automatically ignores time components while maintaining timezone consistency. This method eliminates the complexity of manual date component comparisons and time-related edge cases.

Compare toDateString() values to check if any date represents today.

const isToday = date => new Date().toDateString() === new Date(date).toDateString()

The toDateString() method converts dates to strings like “Sat Oct 05 2025” which includes only the date portion without time information. Comparing these strings ensures that dates with different times but the same calendar day are correctly identified as “today”. This approach handles date objects, timestamps, and date strings uniformly while maintaining local timezone context.

Best Practice Note:

This is the same method we use in CoreUI notification and activity components for accurate “today” filtering. Always validate the input date with isNaN(new Date(date).getTime()) to handle invalid date strings gracefully.


Speed up your responsive apps and websites with fully-featured, ready-to-use open-source admin panel templates—free to use and built for efficiency.


About the Author