WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/07/2019 09:11:37 AM (20 months ago)
Author:
SergeyBiryukov
Message:

Date/Time: Reduce explicit local current_time( 'timestamp' ) usage in favor of native PHP functions.

Timestamps don't carry any timezone information, using the intended format directly simplifies the logic and makes the code less confusing.

Props Rarst, jdgrimes.
See #40657.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/dashboard.php

    r44759 r44809  
    859859        echo '<ul>';
    860860
    861         $today    = date( 'Y-m-d', current_time( 'timestamp' ) );
    862         $tomorrow = date( 'Y-m-d', strtotime( '+1 day', current_time( 'timestamp' ) ) );
     861        $today    = current_time( 'Y-m-d' );
     862        $tomorrow = gmdate( 'Y-m-d', strtotime( '+1 day', current_time( 'timestamp' ) ) );
     863        $year     = current_time( 'Y' );
    863864
    864865        while ( $posts->have_posts() ) {
     
    870871            } elseif ( date( 'Y-m-d', $time ) == $tomorrow ) {
    871872                $relative = __( 'Tomorrow' );
    872             } elseif ( date( 'Y', $time ) !== date( 'Y', current_time( 'timestamp' ) ) ) {
     873            } elseif ( date( 'Y', $time ) !== $year ) {
    873874                /* translators: date and time format for recent posts on the dashboard, from a different calendar year, see https://secure.php.net/date */
    874875                $relative = date_i18n( __( 'M jS Y' ), $time );
Note: See TracChangeset for help on using the changeset viewer.