WordPress.org

Make WordPress Core

Ticket #47494: diff

File diff, 965 bytes (added by zzhovo, 2 years ago)

possible patch

  • ./wp-includes/functions.php

     
    6363 * @return int|string Integer if $type is 'timestamp', string otherwise.
    6464 */
    6565function current_time( $type, $gmt = 0 ) {
     66        $offset = (int)( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
    6667        switch ( $type ) {
    6768                case 'mysql':
    68                         return ( $gmt ) ? gmdate( 'Y-m-d H:i:s' ) : gmdate( 'Y-m-d H:i:s', ( time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) );
     69                        return ( $gmt ) ? gmdate( 'Y-m-d H:i:s' ) : gmdate( 'Y-m-d H:i:s', ( time() + $offset ) );
    6970                case 'timestamp':
    70                         return ( $gmt ) ? time() : time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
     71                        return ( $gmt ) ? time() : time() + $offset;
    7172                default:
    72                         return ( $gmt ) ? gmdate( $type ) : gmdate( $type, time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) );
     73                        return ( $gmt ) ? gmdate( $type ) : gmdate( $type, time() + $offset );
    7374        }
    7475}
    7576