Make WordPress Core


Ignore:
Timestamp:
05/26/2019 12:11:37 AM (6 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/tests/phpunit/tests/admin/includesCommunityEvents.php

    r43356 r45424  
    165165        $this->assertNotWPError( $response );
    166166        $this->assertEqualSetsWithIndex( $this->get_user_location(), $response['location'] );
    167         $this->assertEquals( date( 'l, M j, Y', strtotime( 'next Sunday 1pm' ) ), $response['events'][0]['formatted_date'] );
     167        $this->assertEquals( gmdate( 'l, M j, Y', strtotime( 'next Sunday 1pm' ) ), $response['events'][0]['formatted_date'] );
    168168        $this->assertEquals( '1:00 pm', $response['events'][0]['formatted_time'] );
    169169
     
    186186        $this->assertNotWPError( $cached_events );
    187187        $this->assertEqualSetsWithIndex( $this->get_user_location(), $cached_events['location'] );
    188         $this->assertEquals( date( 'l, M j, Y', strtotime( 'next Sunday 1pm' ) ), $cached_events['events'][0]['formatted_date'] );
     188        $this->assertEquals( gmdate( 'l, M j, Y', strtotime( 'next Sunday 1pm' ) ), $cached_events['events'][0]['formatted_date'] );
    189189        $this->assertEquals( '1:00 pm', $cached_events['events'][0]['formatted_time'] );
    190190
     
    212212                            'meetup'     => 'The East Bay WordPress Meetup Group',
    213213                            'meetup_url' => 'https://www.meetup.com/Eastbay-WordPress-Meetup/',
    214                             'date'       => date( 'Y-m-d H:i:s', strtotime( 'next Sunday 1pm' ) ),
     214                            'date'       => gmdate( 'Y-m-d H:i:s', strtotime( 'next Sunday 1pm' ) ),
    215215                            'location'   => array(
    216216                                'location'  => 'Oakland, CA, USA',
     
    226226                            'meetup'     => 'WordPress Bay Area Foothills Group',
    227227                            'meetup_url' => 'https://www.meetup.com/Wordpress-Bay-Area-CA-Foothills/',
    228                             'date'       => date( 'Y-m-d H:i:s', strtotime( 'next Wednesday 1:30pm' ) ),
     228                            'date'       => gmdate( 'Y-m-d H:i:s', strtotime( 'next Wednesday 1:30pm' ) ),
    229229                            'location'   => array(
    230230                                'location'  => 'Milpitas, CA, USA',
     
    240240                            'meetup'     => null,
    241241                            'meetup_url' => null,
    242                             'date'       => date( 'Y-m-d H:i:s', strtotime( 'next Saturday' ) ),
     242                            'date'       => gmdate( 'Y-m-d H:i:s', strtotime( 'next Saturday' ) ),
    243243                            'location'   => array(
    244244                                'location'  => 'Kansas City, MO',
     
    304304                            'meetup'     => 'The East Bay WordPress Meetup Group',
    305305                            'meetup_url' => 'https://www.meetup.com/Eastbay-WordPress-Meetup/',
    306                             'date'       => date( 'Y-m-d H:i:s', strtotime( 'next Monday 1pm' ) ),
     306                            'date'       => gmdate( 'Y-m-d H:i:s', strtotime( 'next Monday 1pm' ) ),
    307307                            'location'   => array(
    308308                                'location'  => 'Oakland, CA, USA',
     
    318318                            'meetup'     => 'WordPress Bay Area Foothills Group',
    319319                            'meetup_url' => 'https://www.meetup.com/Wordpress-Bay-Area-CA-Foothills/',
    320                             'date'       => date( 'Y-m-d H:i:s', strtotime( 'next Tuesday 1:30pm' ) ),
     320                            'date'       => gmdate( 'Y-m-d H:i:s', strtotime( 'next Tuesday 1:30pm' ) ),
    321321                            'location'   => array(
    322322                                'location'  => 'Milpitas, CA, USA',
     
    332332                            'meetup'     => 'The San Jose WordPress Meetup',
    333333                            'meetup_url' => 'https://www.meetup.com/sanjosewp/',
    334                             'date'       => date( 'Y-m-d H:i:s', strtotime( 'next Wednesday 5:30pm' ) ),
     334                            'date'       => gmdate( 'Y-m-d H:i:s', strtotime( 'next Wednesday 5:30pm' ) ),
    335335                            'location'   => array(
    336336                                'location'  => 'Milpitas, CA, USA',
     
    346346                            'meetup'     => null,
    347347                            'meetup_url' => null,
    348                             'date'       => date( 'Y-m-d H:i:s', strtotime( 'next Thursday 9am' ) ),
     348                            'date'       => gmdate( 'Y-m-d H:i:s', strtotime( 'next Thursday 9am' ) ),
    349349                            'location'   => array(
    350350                                'location'  => 'San Diego, CA',
     
    407407                            'meetup'     => 'The East Bay WordPress Meetup Group',
    408408                            'meetup_url' => 'https://www.meetup.com/Eastbay-WordPress-Meetup/',
    409                             'date'       => date( 'Y-m-d H:i:s', strtotime( '2 days ago' ) ),
     409                            'date'       => gmdate( 'Y-m-d H:i:s', strtotime( '2 days ago' ) ),
    410410                            'location'   => array(
    411411                                'location'  => 'Oakland, CA, USA',
     
    421421                            'meetup'     => null,
    422422                            'meetup_url' => null,
    423                             'date'       => date( 'Y-m-d H:i:s', strtotime( 'next Tuesday 9am' ) ),
     423                            'date'       => gmdate( 'Y-m-d H:i:s', strtotime( 'next Tuesday 9am' ) ),
    424424                            'location'   => array(
    425425                                'location'  => 'San Diego, CA',
     
    435435                            'meetup'     => 'WordPress Bay Area Foothills Group',
    436436                            'meetup_url' => 'https://www.meetup.com/Wordpress-Bay-Area-CA-Foothills/',
    437                             'date'       => date( 'Y-m-d H:i:s', strtotime( 'next Wednesday 1:30pm' ) ),
     437                            'date'       => gmdate( 'Y-m-d H:i:s', strtotime( 'next Wednesday 1:30pm' ) ),
    438438                            'location'   => array(
    439439                                'location'  => 'Milpitas, CA, USA',
     
    449449                            'meetup'     => 'The San Jose WordPress Meetup',
    450450                            'meetup_url' => 'https://www.meetup.com/sanjosewp/',
    451                             'date'       => date( 'Y-m-d H:i:s', strtotime( 'next Thursday 5:30pm' ) ),
     451                            'date'       => gmdate( 'Y-m-d H:i:s', strtotime( 'next Thursday 5:30pm' ) ),
    452452                            'location'   => array(
    453453                                'location'  => 'Milpitas, CA, USA',
     
    463463                            'meetup'     => null,
    464464                            'meetup_url' => null,
    465                             'date'       => date( 'Y-m-d H:i:s', strtotime( 'next Friday 9am' ) ),
     465                            'date'       => gmdate( 'Y-m-d H:i:s', strtotime( 'next Friday 9am' ) ),
    466466                            'location'   => array(
    467467                                'location'  => 'Los Angeles, CA',
Note: See TracChangeset for help on using the changeset viewer.