var today = new Date();
alert(today);
How to add this code??
var today = new Date();
alert(today);
How to add this code??
By @MJ ST
You would research how to work with dates with JavaScript, among a few other things.
Here is a working demo for you. It is not guaranteed to be fit for purpose or covered by warranty. Use at your own risk!
/*
Today's date: 2024-10-18
Expires tomorrow: 2024-10-19
*/
// Get today's date
var today = new Date();
var year = today.getFullYear().toString();
// Extract the month... Months are zero indexed, so add one!
var month = ("0" + (today.getMonth() + 1)).slice(-2);
var date = ("0" + today.getDate()).slice(-2);
var yyyymmdd = year.toString() + month.toString() + date.toString();
// Convert the string back to a number
yyyymmdd = parseInt(yyyymmdd);
// Conditional
if (yyyymmdd < 20241019) {
// Add your code below. Remove the following alert...
alert("Pass");
} else {
// Do nothing on fail. Remove the following alert...
alert("Fail");
}