diff --git a/phpBB/includes/datetime.php b/phpBB/includes/datetime.php index 317376431d..0d80c77115 100644 --- a/phpBB/includes/datetime.php +++ b/phpBB/includes/datetime.php @@ -35,10 +35,9 @@ class phpbb_datetime extends DateTime * @param DateTimeZone $timezone Time zone of the time. * @param user User object for context. */ - public function __construct($time = 'now', DateTimeZone $timezone = null, $user = null) + public function __construct($user, $time = 'now', DateTimeZone $timezone = null) { - $this->user = $user ?: $GLOBALS['user']; - + $this->user = $user; $timezone = $timezone ?: $this->user->tz; parent::__construct($time, $timezone); @@ -56,7 +55,7 @@ class phpbb_datetime extends DateTime $format = $format ? $format : $this->user->date_format; $format = self::format_cache($format, $this->user); $relative = ($format['is_short'] && !$force_absolute); - $now = new self('now', $this->user->tz, $this->user); + $now = new self($this->user, 'now', $this->user->tz); $timestamp = $this->getTimestamp(); $now_ts = $now->getTimeStamp(); diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 98a08ea4d3..4fc2739f33 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1164,7 +1164,7 @@ function tz_select($default = '', $truncate = false, $return_tzs_only = true) foreach ($unsorted_timezones as $timezone) { $tz = new DateTimeZone($timezone); - $dt = new phpbb_datetime('now', $tz, $user); + $dt = new phpbb_datetime($user, 'now', $tz); $offset = $dt->getOffset(); $current_time = $dt->format($user->lang['DATETIME_FORMAT'], true); $offset_string = phpbb_format_timezone_offset($offset); @@ -4813,7 +4813,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 } } - $dt = new phpbb_datetime('now', $user->tz, $user); + $dt = new phpbb_datetime($user, 'now', $user->tz); $timezone_offset = 'GMT' . phpbb_format_timezone_offset($dt->getOffset()); $timezone_name = $user->tz->getName(); if (isset($user->lang['timezones'][$timezone_name])) diff --git a/phpBB/includes/user.php b/phpBB/includes/user.php index df8f048c89..cc50d2b98e 100644 --- a/phpBB/includes/user.php +++ b/phpBB/includes/user.php @@ -631,7 +631,7 @@ class phpbb_user extends phpbb_session $utc = new DateTimeZone('UTC'); } - $time = new phpbb_datetime("@$gmepoch", $utc, $this); + $time = new phpbb_datetime($this, "@$gmepoch", $utc); $time->setTimezone($this->tz); return $time->format($format, $forcedate); @@ -648,7 +648,7 @@ class phpbb_user extends phpbb_session public function create_datetime($time = 'now', DateTimeZone $timezone = null) { $timezone = $timezone ?: $this->tz; - return new phpbb_datetime($time, $timezone, $this); + return new phpbb_datetime($this, $time, $timezone); } /**