WordPress.org

Make WordPress Core


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

    r43571 r45424  
    533533        for ( $j = 1; $j < 3; $j++ ) {
    534534            // Manually modify dates to ensure they're different.
    535             $date                                  = date( 'Y-m-d H:i:s', $now - ( $j * 10 ) );
     535            $date                                  = gmdate( 'Y-m-d H:i:s', $now - ( $j * 10 ) );
    536536            $post_revision_fields['post_date']     = $date;
    537537            $post_revision_fields['post_date_gmt'] = $date;
     
    564564
    565565        $revision_ids = array();
    566         $date         = date( 'Y-m-d H:i:s', time() - 10 );
     566        $date         = gmdate( 'Y-m-d H:i:s', time() - 10 );
    567567        for ( $j = 1; $j < 3; $j++ ) {
    568568            // Manually modify dates to ensure they're the same.
Note: See TracChangeset for help on using the changeset viewer.