diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 32fe225564..7acc75beaf 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -46,13 +46,14 @@ function mysql2date( $format, $date, $translate = true ) { * * 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 Either 'mysql' or 'timestamp'. + * @param string $type 'mysql', 'timestamp', or PHP date format string (e.g. 'Y-m-d'). * @param int|bool $gmt Optional. Whether to use GMT timezone. Default is false. * @return int|string String if $type is 'gmt', int if $type is 'timestamp'. */ @@ -64,6 +65,9 @@ function current_time( $type, $gmt = 0 ) { case 'timestamp': return ( $gmt ) ? time() : time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); break; + default: + return ( $gmt ) ? date( $type ) : date( $type, time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ); + break; } }