0

How do I redirect URL based on the time of day in London. I've seen methods of doing it with javascript that uses the local machine time and other methods using PHP that uses the server location time. With the PHP method the server has to be set in London time in order for that to work but I have no access to that. Is there a way to do a redirect that follows the time of day in London no matter where the client is in the world?

zonogon
  • 5
  • 2

2 Answers2

0

You can use

$_SERVER['REQUEST_TIME'];

It will return the current UNIX Timestamp.

http://ch1.php.net/manual/en/function.time.php

This is the manual page from the php docs

flightsearch
  • 79
  • 2
  • 10
0

Try something like this:

<?php date_default_timezone_set('Europe/London');
$time = date("H");
if($time<12){
  header("Location: siteerly.php");
  exit();
}
else{
  header("Location: siteelse.php");
  exit();
}

You can modify it as you like. Remember to put this code before you output any html code.

Sebastian Td
  • 174
  • 1
  • 7