Check if date is today
Question:
How to check if date is today? Answer:
new Date().toDateString() === testDate.toDateString()
Description:
If you want to check if a given Date is today then simply use the toDateString()
method. The toDateString()
method returns the date portion of a Date object
Reference:
toDateString reference
Share "How to check if date is today?"
Related snippets:
- Convert milliseconds to minutes and seconds
- Check if date is valid in JavaScript
- Generate random date with JavaScript
- Generate random date in a range with JavaScript
- Check if date is today
- Get month name from Date in JavaScript
- Get the current date in JavaScript
- Get difference between 2 dates in JavaScript
- Get yesterday's date in JavaScript
- Get tomorrow's date in JavaScript
Tags:
javascript date today, check if date is today Technical term:
Check if date is today