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/template.php

    r44759 r44809  
    775775    // echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />';
    776776
    777     $time_adj  = current_time( 'timestamp' );
    778777    $post_date = ( $for_post ) ? $post->post_date : get_comment()->comment_date;
    779     $jj        = ( $edit ) ? mysql2date( 'd', $post_date, false ) : gmdate( 'd', $time_adj );
    780     $mm        = ( $edit ) ? mysql2date( 'm', $post_date, false ) : gmdate( 'm', $time_adj );
    781     $aa        = ( $edit ) ? mysql2date( 'Y', $post_date, false ) : gmdate( 'Y', $time_adj );
    782     $hh        = ( $edit ) ? mysql2date( 'H', $post_date, false ) : gmdate( 'H', $time_adj );
    783     $mn        = ( $edit ) ? mysql2date( 'i', $post_date, false ) : gmdate( 'i', $time_adj );
    784     $ss        = ( $edit ) ? mysql2date( 's', $post_date, false ) : gmdate( 's', $time_adj );
    785 
    786     $cur_jj = gmdate( 'd', $time_adj );
    787     $cur_mm = gmdate( 'm', $time_adj );
    788     $cur_aa = gmdate( 'Y', $time_adj );
    789     $cur_hh = gmdate( 'H', $time_adj );
    790     $cur_mn = gmdate( 'i', $time_adj );
     778    $jj        = ( $edit ) ? mysql2date( 'd', $post_date, false ) : current_time( 'd' );
     779    $mm        = ( $edit ) ? mysql2date( 'm', $post_date, false ) : current_time( 'm' );
     780    $aa        = ( $edit ) ? mysql2date( 'Y', $post_date, false ) : current_time( 'Y' );
     781    $hh        = ( $edit ) ? mysql2date( 'H', $post_date, false ) : current_time( 'H' );
     782    $mn        = ( $edit ) ? mysql2date( 'i', $post_date, false ) : current_time( 'i' );
     783    $ss        = ( $edit ) ? mysql2date( 's', $post_date, false ) : current_time( 's' );
     784
     785    $cur_jj = current_time( 'd' );
     786    $cur_mm = current_time( 'm' );
     787    $cur_aa = current_time( 'Y' );
     788    $cur_hh = current_time( 'H' );
     789    $cur_mn = current_time( 'i' );
    791790
    792791    $month = '<label><span class="screen-reader-text">' . __( 'Month' ) . '</span><select ' . ( $multi ? '' : 'id="mm" ' ) . 'name="mm"' . $tab_index_attribute . ">\n";
Note: See TracChangeset for help on using the changeset viewer.