wpseek.com
A WordPress-centric search engine for devs and theme authors
current_time › WordPress Function
Since1.0.0
Deprecatedn/a
› current_time ( $type, $gmt = 0 )
Parameters: (2) |
|
Returns: |
|
Defined at: |
|
Codex: |
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. 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.
Related Functions: current_filter, current_action, get_current_theme, comment_time, current_theme_info
Source
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' ) * HOUR_IN_SECONDS ) ) ); case 'timestamp': return ( $gmt ) ? time() : time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); default: return ( $gmt ) ? date( $type ) : date( $type, time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ); } }