mirror of
https://github.com/WordPress/WordPress.git
synced 2025-03-09 07:00:01 +00:00
Allow current_time() to accept a date format string, adding to 'timestamp' and 'mysql'.
props danielbachhuber. fixes #21653. Built from https://develop.svn.wordpress.org/trunk@27259 git-svn-id: http://core.svn.wordpress.org/trunk@27116 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
7387504854
commit
237941babc
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user