Skip to content

Instantly share code, notes, and snippets.

@cesarhdz
Created March 18, 2012 23:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cesarhdz/2084940 to your computer and use it in GitHub Desktop.
Save cesarhdz/2084940 to your computer and use it in GitHub Desktop.
PHP:WP:current_time
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;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment