screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Check if Date is Today</title> <script> function isDateToday(dateToCheck) { var currentDate = new Date(); var isToday = dateToCheck.getFullYear() === currentDate.getFullYear() && dateToCheck.getMonth() === currentDate.getMonth() && dateToCheck.getDate() === currentDate.getDate(); return isToday; } function checkDate() { var dateString = document.getElementById('dateInput').value; var dateToCheck = new Date(dateString); // Creates a date object from the input if (isDateToday(dateToCheck)) { alert('The date is today.'); } else { alert('The date is not today.'); } } </script> </head> <body> <h2>Javascript Check if Date is Today</h2> <label for="dateInput">Enter a Date:</label> <input type="date" id="dateInput"> <button onclick="checkDate()">Check</button> </body> </html>