WordPress.org

Make WordPress Core

Ticket #47464: current-datetime.patch

File current-datetime.patch, 1.3 KB (added by Rarst, 4 months ago)
  • src/wp-includes/functions.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    7373        }
    7474}
    7575
     76/**
     77 * Retrieve the current time as an object with the settings time zone.
     78 *
     79 * @return DateTimeImmutable
     80 */
     81function current_datetime() {
     82
     83        return new DateTimeImmutable( 'now', wp_timezone() );
     84}
     85
    7686/**
    7787 * Retrieve the date in localized format, based on a sum of Unix timestamp and
    7888 * timezone offset in seconds.
  • src/wp-admin/includes/dashboard.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    856856                echo '<ul>';
    857857
    858858                $today    = current_time( 'Y-m-d' );
    859                 $tomorrow = gmdate( 'Y-m-d', strtotime( '+1 day', current_time( 'timestamp' ) ) );
     859                $tomorrow = current_datetime()->modify('+1 day')->format('Y-m-d');
    860860                $year     = current_time( 'Y' );
    861861
    862862                while ( $posts->have_posts() ) {