Commit 8a18508e authored by Andrew Nacin's avatar Andrew Nacin
Browse files

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: https://core.svn.wordpress.org/trunk@27116 1a063a9b-81f0-0310-95a4-ce76da25c4cd
parent 0955a2a2
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -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;
	}
}