From 990cbe093b65e12effaa430cd7aa7735258b11fe Mon Sep 17 00:00:00 2001 From: rxu Date: Sun, 29 Sep 2024 01:57:53 +0700 Subject: [PATCH] [ticket/17405] Fix getting UTC date/time information logic PHPBB-17405 --- phpBB/includes/functions.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 389b31bb8c..0627fdc8b3 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -107,9 +107,17 @@ function phpbb_gmgetdate($time = false) } // getdate() interprets timestamps in local time. - // What follows uses the fact that getdate() and - // date('Z') balance each other out. - return getdate($time - date('Z')); + // So use UTC timezone temporarily to get UTC date info array. + $current_timezone = date_default_timezone_get(); + + // Set UTC timezone and get respective date info + date_default_timezone_set('UTC'); + $date_info = getdate($time); + + // Restore timezone back + date_default_timezone_set($current_timezone); + + return $date_info; } /**