I’m using this code to redirect based on the hour of the day, and the day of the week.
Here it is ..
<?php
$hour = date('G');
$minute = date('i');
$day = date('w');
$m = $hour * 60 + $minute; // Minutes since midnight.
if (
$day == 0 // Sunday...
&& $m >= 615 // ... after 10:15…
&& $m <= 700 // ... but before 11:40…
) {
header("Location: open.php");
}
else
if (
$day == 3 // Wednesday...
&& $m >= 1125 // ... after 18:45…
&& $m <= 1235 // ... but before 20:35…
) {
header("Location: open.php");
}
?>
I was wondering if there was a way to redirect to a page based on an exact date in the future like April 25th or November 1st.
Thanks .
This is a simple approach, which does not take account the year date:
Look at the date() documentation for more exact details.