Make WordPress Core


Ignore:
Timestamp:
05/26/2019 12:11:37 AM (5 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/post/listPages.php

    r42402 r45424  
    5050        self::$time = time();
    5151
    52         $post_date = date( 'Y-m-d H:i:s', self::$time );
     52        $post_date = gmdate( 'Y-m-d H:i:s', self::$time );
    5353
    5454        self::$parent_1 = self::factory()->post->create(
     
    158158            'show_date' => true,
    159159        );
    160         $date = date( get_option( 'date_format' ), self::$time );
     160        $date = gmdate( get_option( 'date_format' ), self::$time );
    161161
    162162        $expected = '<li class="pagenav">Pages<ul><li class="page_item page-item-' . self::$parent_1 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_1 ) . '">Parent 1</a> ' . $date . '</li>
     
    174174            'date_format' => 'l, F j, Y',
    175175        );
    176         $date = date( $args['date_format'], self::$time );
     176        $date = gmdate( $args['date_format'], self::$time );
    177177
    178178        $expected = '<li class="pagenav">Pages<ul><li class="page_item page-item-' . self::$parent_1 . ' page_item_has_children"><a href="' . get_permalink( self::$parent_1 ) . '">Parent 1</a> ' . $date . '
Note: See TracChangeset for help on using the changeset viewer.