Allow current_time() to accept a date format string, adding to 'timestamp' and 'mysql'.
props danielbachhuber. fixes #21653. git-svn-id: https://develop.svn.wordpress.org/trunk@27259 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
a407ae2363
commit
1916576840
@ -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 'mysql' type will return the time in the format for MySQL DATETIME field.
|
||||||
* The 'timestamp' type will return the current timestamp.
|
* 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 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.
|
* if $gmt is false, the output is adjusted with the GMT offset in the WordPress option.
|
||||||
*
|
*
|
||||||
* @since 1.0.0
|
* @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.
|
* @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'.
|
* @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':
|
case 'timestamp':
|
||||||
return ( $gmt ) ? time() : time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
|
return ( $gmt ) ? time() : time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
return ( $gmt ) ? date( $type ) : date( $type, time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) );
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user