Definition:
function current_time( $type, $gmt = 0 ) {}
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.
Parameters
- string $type: Either ‘mysql’ or ‘timestamp’.
- int|bool $gmt: Optional. Whether to use GMT timezone. Default is false.
Return values
returns:String if $type is ‘gmt’, int if $type is ‘timestamp’.
Source code
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' ) * 3600 ) ) );
break;
case 'timestamp':
return ( $gmt ) ? time() : time() + ( get_option( 'gmt_offset' ) * 3600 );
break;
}
}
754

February 11, 2011 


No comments yet... Be the first to leave a reply!