0

Our current hosting company is based in Canada so obviously their times are different to the UK.

Is there any way in PHP to display the Date/Time but get it from a different server if i specify the IP?

2
  • 7
    Using timezones would be a better idea Commented Apr 15, 2013 at 13:25
  • If you know the location of each of these servers, then why don't you manually input the time zones for each and echo them out? + Store the IP as an array for future reference Commented Apr 15, 2013 at 13:27

2 Answers 2

1

you can use date_default_timezone_set (see documentation) function to set your actual script time to whatever you need

example for Rome

date_default_timezone_set('Europe/Rome');
Sign up to request clarification or add additional context in comments.

Comments

0

Using timezones would be a better idea.

$now = new DateTime(null, new DateTimeZone('America/Toronto'));
$now->setTimezone(new DateTimeZone('Europe/London'));
echo now->format('Y-m-d H:i:s);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.