Jump to content

Will This Work?


westman

Recommended Posts

am looking to output the date of London,UK not the serverdate_default_timezone_set('Europe/London');$day = date('d');$month = date('m');$year = date('Y');$nextMonday = date("Y, m, d",strtotime('next Monday',mktime(0,0,0,$month,$day,$year)));echo $nextMonday;will this work?

Link to comment
Share on other sites

date_default_timezone_set() will assume that your server's current time is in said timezone. It is NOT going to adjust date calculations.To do that, you'll need to first create a DateTime object, and then set its timezone, like:

$date = new DateTime();echo $date->format('Y-m-d H:i:sP') . "\n";//Current time in your server's timezone$date->setTimezone(new DateTimeZone('Europe/London'));echo $date->format('Y-m-d H:i:sP') . "\n";//Current time in the Europe/London timezone

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...