Advertisements

current_time

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

Advertisements

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: