im trying to make a my index.html file redirect o another html file after i reach a certain date and time (noob here)
this is my code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>title</title>
<script language="javascript">
var currentdate = new Date();
var datetime = "Last Sync: " + currentdate.getDate() + "/" + (currentdate.getMonth() + 1) +
"/" + currentdate.getFullYear() + " @ " +
currentdate.getHours() + ":" +
currentdate.getMinutes();
var dateAfter = new Date('2023-08-5T00:00:00');
if (currentdate > dateAfter) // Datum omschakeling
{
location.href = "redirect.html";
}
</script>
</head>
<body>
</body>
</html>
And i should go to redirect.html but its not
2
Answers
You should add window object:
Your
dateAfter
is invalid.change
to