Міша Басараб Міша Басараб - 23 days ago 6
HTML Question

I need to do a site redirects to a page after 21.45 to 10.00

I need to do a site redirects to a page after 21.45 to 10.00
I need a script that would do a redirect site to another page at a certain time.

Here's what happened.

<?php
$date = new DateTime('now');
$date->setTimezone(new DateTimeZone('Europe/Athens'));
if ($date->format('H')>=10 && $date->format('H')<=21 ){
if ($date->format('H')==21 && $date->format('i')<45)
echo "<script>window.location = '/'</script>";
else if($date->format('H')<21)
echo "<script>window.location = '/'</script>";
}
?>

Answer

Not really sure with timezone, but

$hoursMinutes = intval(date("Hi"));
if($hoursMinutes >= 1000 && $hoursMinutes <=2145) {
    header("Location: /2");
} else {
    header("Location: /1");
}