CoreUI ONE — 250+ PRO components and 25+ admin templates for React, Angular, Vue, Bootstrap and Next.js, plus Data Grid, Scheduler, 4,300+ PRO icons and the Next.js boilerplate. One license. → See what you get

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, 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

Subscribe to our newsletter
Get early information about new products, product updates and blog posts.
How to Redirect to a New URL Using JavaScript Redirect Techniques
How to Redirect to a New URL Using JavaScript Redirect Techniques

How to Achieve Perfectly Rounded Corners in CSS
How to Achieve Perfectly Rounded Corners in CSS

How to Add a Tab in HTML
How to Add a Tab in HTML

How to Open Link in a New Tab in HTML?
How to Open Link in a New Tab in HTML?