mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-30 23:30:05 +00:00
Date/Time: Replace all instances of date() with gmdate().
Use of `date()` in core depends on PHP timezone set to UTC and not changed by third party code (which cannot be guaranteed). `gmdate()` is functionally equivalent, but is not affected by PHP timezone setting: it's always UTC, which is the exact behavior the core needs. Props nielsdeblaauw, Rarst. Fixes #46438. See #44491. git-svn-id: https://develop.svn.wordpress.org/trunk@45424 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -41,7 +41,7 @@ function mysql2date( $format, $date, $translate = true ) {
|
||||
if ( $translate ) {
|
||||
return date_i18n( $format, $i );
|
||||
} else {
|
||||
return date( $format, $i );
|
||||
return gmdate( $format, $i );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,12 +111,12 @@ function date_i18n( $dateformatstring, $timestamp_with_offset = false, $gmt = fa
|
||||
$dateformatstring = preg_replace( '/(?<!\\\\)r/', DATE_RFC2822, $dateformatstring );
|
||||
|
||||
if ( ( ! empty( $wp_locale->month ) ) && ( ! empty( $wp_locale->weekday ) ) ) {
|
||||
$datemonth = $wp_locale->get_month( date( 'm', $i ) );
|
||||
$datemonth = $wp_locale->get_month( gmdate( 'm', $i ) );
|
||||
$datemonth_abbrev = $wp_locale->get_month_abbrev( $datemonth );
|
||||
$dateweekday = $wp_locale->get_weekday( date( 'w', $i ) );
|
||||
$dateweekday = $wp_locale->get_weekday( gmdate( 'w', $i ) );
|
||||
$dateweekday_abbrev = $wp_locale->get_weekday_abbrev( $dateweekday );
|
||||
$datemeridiem = $wp_locale->get_meridiem( date( 'a', $i ) );
|
||||
$datemeridiem_capital = $wp_locale->get_meridiem( date( 'A', $i ) );
|
||||
$datemeridiem = $wp_locale->get_meridiem( gmdate( 'a', $i ) );
|
||||
$datemeridiem_capital = $wp_locale->get_meridiem( gmdate( 'A', $i ) );
|
||||
$dateformatstring = ' ' . $dateformatstring;
|
||||
$dateformatstring = preg_replace( '/([^\\\])D/', "\\1" . backslashit( $dateweekday_abbrev ), $dateformatstring );
|
||||
$dateformatstring = preg_replace( '/([^\\\])F/', "\\1" . backslashit( $datemonth ), $dateformatstring );
|
||||
@@ -177,7 +177,7 @@ function date_i18n( $dateformatstring, $timestamp_with_offset = false, $gmt = fa
|
||||
}
|
||||
}
|
||||
}
|
||||
$j = @date( $dateformatstring, $i );
|
||||
$j = @gmdate( $dateformatstring, $i );
|
||||
|
||||
/**
|
||||
* Filters the date formatted based on the locale.
|
||||
@@ -415,7 +415,7 @@ function get_weekstartend( $mysqlstring, $start_of_week = '' ) {
|
||||
$day = mktime( 0, 0, 0, $md, $mm, $my );
|
||||
|
||||
// The day of the week from the timestamp.
|
||||
$weekday = date( 'w', $day );
|
||||
$weekday = gmdate( 'w', $day );
|
||||
|
||||
if ( ! is_numeric( $start_of_week ) ) {
|
||||
$start_of_week = get_option( 'start_of_week' );
|
||||
|
||||
Reference in New Issue
Block a user