From 9156163ca61b9230c3edcef760f5b330c9b398e5 Mon Sep 17 00:00:00 2001 From: Jonny Harris Date: Tue, 14 Feb 2023 21:39:43 +0000 Subject: [PATCH] Date/Time: Save a call to wp_timezone in mysql2date. Save a call to `wp_timezone` in `mysql2date` by saving the timezone to a variable and pass it into `wp_date` function call. Props spacedmonkey, costdev, SergeyBiryukov, audrasjb. Fixes #57705. git-svn-id: https://develop.svn.wordpress.org/trunk@55343 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/functions.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 0c51e9d7ab..c59f86877f 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -32,7 +32,8 @@ function mysql2date( $format, $date, $translate = true ) { return false; } - $datetime = date_create( $date, wp_timezone() ); + $timezone = wp_timezone(); + $datetime = date_create( $date, $timezone ); if ( false === $datetime ) { return false; @@ -44,7 +45,7 @@ function mysql2date( $format, $date, $translate = true ) { } if ( $translate ) { - return wp_date( $format, $datetime->getTimestamp() ); + return wp_date( $format, $datetime->getTimestamp(), $timezone ); } return $datetime->format( $format );