Misleading doc-block description for the current_time() $gmt parameter
-
Hi there,
I’d like to point out the doc-block description might be misleading for the
current_time()
function parameter,$gmt
./** * Retrieve the current time based on specified type. * * The 'mysql' type will return the time in the format for MySQL DATETIME field. * The 'timestamp' type will return the current timestamp. * Other strings will be interpreted as PHP date formats (e.g. 'Y-m-d'). * * If $gmt is set to either '1' or 'true', then both types will use GMT time. * if $gmt is false, the output is adjusted with the GMT offset in the WordPress option. * * @since 1.0.0 * * @param string $type Type of time to retrieve. Accepts 'mysql', 'timestamp', or PHP date * format string (e.g. 'Y-m-d'). * @param int|bool $gmt Optional. Whether to use GMT timezone. Default false. * @return int|string Integer if $type is 'timestamp', string otherwise. */ function current_time( $type, $gmt = 0 ) { switch ( $type ) { case 'mysql': return ( $gmt ) ? gmdate( 'Y-m-d H:i:s' ) : gmdate( 'Y-m-d H:i:s', ( time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) ); case 'timestamp': return ( $gmt ) ? time() : time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); default: return ( $gmt ) ? date( $type ) : date( $type, time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ); } }
@param int|bool $gmt Optional. Whether to use GMT timezone. Default false.
I thought by passing
false
, the GMT offset will not be applied. But looking at the code, it’s opposite.Shouldn’t the description be rephrased to something like “Whether to unuse GMT timezone.”?
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Misleading doc-block description for the current_time() $gmt parameter’ is closed to new replies.