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-includes/date.php

    r42877 r45424  
    318318            }
    319319
    320             $max_days_of_year = date( 'z', mktime( 0, 0, 0, 12, 31, $_year ) ) + 1;
     320            $max_days_of_year = gmdate( 'z', mktime( 0, 0, 0, 12, 31, $_year ) ) + 1;
    321321        } else {
    322322            // otherwise we use the max of 366 (leap-year)
     
    353353             * Note: the number of weeks in a year is the date in which Dec 28 appears.
    354354             */
    355             $week_count = date( 'W', mktime( 0, 0, 0, 12, 28, $_year ) );
     355            $week_count = gmdate( 'W', mktime( 0, 0, 0, 12, 28, $_year ) );
    356356
    357357        } else {
     
    924924
    925925        if ( ! isset( $datetime['day'] ) ) {
    926             $datetime['day'] = ( $default_to_max ) ? (int) date( 't', mktime( 0, 0, 0, $datetime['month'], 1, $datetime['year'] ) ) : 1;
     926            $datetime['day'] = ( $default_to_max ) ? (int) gmdate( 't', mktime( 0, 0, 0, $datetime['month'], 1, $datetime['year'] ) ) : 1;
    927927        }
    928928
Note: See TracChangeset for help on using the changeset viewer.