current_time

Retrieve the current time based on specified type.

Description

(int|string) current_time( (string) $type, (int) $gmt = 0 ); 

The mysql type will return the time in the format for MySQL DATETIME field. The timestamp, type will return the current timestamp.

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.

Returns (int|string)

String if $type is 'gmt', int if $type is 'timestamp'.

Parameters (2)

0. $type (string)
Either mysql or timestamp..
1. $gmt — Optional. (int)
Whether to use GMT timezone. Default is false.

Usage

  1. if ( !function_exists( 'current_time' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-includes/backpress/functions.core.php'; 
  3.  
  4. // Either 'mysql' or 'timestamp'. 
  5. $type = ''; 
  6.  
  7. // Optional. Whether to use GMT timezone. Default is false. 
  8. $gmt = -1; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = current_time($type, $gmt); 
  12.  

Defined (1)

The function is defined in the following location(s).

/bp-forums/bbpress/bb-includes/backpress/functions.core.php  
  1. function current_time( $type, $gmt = 0 ) { 
  2. switch ( $type ) { 
  3. case 'mysql': 
  4. return ( $gmt ) ? gmdate( 'Y-m-d H:i:s' ) : gmdate( 'Y-m-d H:i:s', ( time() + ( backpress_get_option( 'gmt_offset' ) * 3600 ) ) ); 
  5. break; 
  6. case 'timestamp': 
  7. return ( $gmt ) ? time() : time() + ( backpress_get_option( 'gmt_offset' ) * 3600 ); 
  8. break;