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/src/wp-admin/includes/export.php

    r45216 r45424  
    8080        $sitename .= '.';
    8181    }
    82     $date        = date( 'Y-m-d' );
     82    $date        = gmdate( 'Y-m-d' );
    8383    $wp_filename = $sitename . 'WordPress.' . $date . '.xml';
    8484    /**
     
    130130
    131131        if ( $args['start_date'] ) {
    132             $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date >= %s", date( 'Y-m-d', strtotime( $args['start_date'] ) ) );
     132            $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date >= %s", gmdate( 'Y-m-d', strtotime( $args['start_date'] ) ) );
    133133        }
    134134
    135135        if ( $args['end_date'] ) {
    136             $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date < %s", date( 'Y-m-d', strtotime( '+1 month', strtotime( $args['end_date'] ) ) ) );
     136            $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date < %s", gmdate( 'Y-m-d', strtotime( '+1 month', strtotime( $args['end_date'] ) ) ) );
    137137        }
    138138    }
     
    459459    <link><?php bloginfo_rss( 'url' ); ?></link>
    460460    <description><?php bloginfo_rss( 'description' ); ?></description>
    461     <pubDate><?php echo date( 'D, d M Y H:i:s +0000' ); ?></pubDate>
     461    <pubDate><?php echo gmdate( 'D, d M Y H:i:s +0000' ); ?></pubDate>
    462462    <language><?php bloginfo_rss( 'language' ); ?></language>
    463463    <wp:wxr_version><?php echo WXR_VERSION; ?></wp:wxr_version>
Note: See TracChangeset for help on using the changeset viewer.