Make WordPress Core


Ignore:
Timestamp:
05/26/2019 12:11:37 AM (7 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/formatting.php

    r45418 r45424  
    34333433                $datetime = date_create( $string, new DateTimeZone( 'UTC' ) );
    34343434                if ( ! $datetime ) {
    3435                         return date( $format, 0 );
     3435                        return gmdate( $format, 0 );
    34363436                }
    34373437                $datetime->setTimezone( new DateTimeZone( $tz ) );
     
    34393439        } else {
    34403440                if ( ! preg_match( '#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches ) ) {
    3441                         return date( $format, 0 );
     3441                        return gmdate( $format, 0 );
    34423442                }
    34433443                $string_time      = gmmktime( $matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1] );
Note: See TracChangeset for help on using the changeset viewer.