クラス WP_Date_Query::build_mysql_datetime()
2014/12/16
WP_Date_Query::build_mysql_datetime()
定義ファイル :/blog/wp-includes/date.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | public function build_mysql_datetime( $datetime, $default_to_max = false ) { $now = current_time( 'timestamp' ); if ( ! is_array( $datetime ) ) { // @todo Timezone issues here possibly return gmdate( 'Y-m-d H:i:s', strtotime( $datetime, $now ) ); } $datetime = array_map( 'absint', $datetime ); if ( ! isset( $datetime['year'] ) ) $datetime['year'] = gmdate( 'Y', $now ); if ( ! isset( $datetime['month'] ) ) $datetime['month'] = ( $default_to_max ) ? 12 : 1; if ( ! isset( $datetime['day'] ) ) $datetime['day'] = ( $default_to_max ) ? (int) date( 't', mktime( 0, 0, 0, $datetime['month'], 1, $datetime['year'] ) ) : 1; if ( ! isset( $datetime['hour'] ) ) $datetime['hour'] = ( $default_to_max ) ? 23 : 0; if ( ! isset( $datetime['minute'] ) ) $datetime['minute'] = ( $default_to_max ) ? 59 : 0; if ( ! isset( $datetime['second'] ) ) $datetime['second'] = ( $default_to_max ) ? 59 : 0; return sprintf( '%04d-%02d-%02d %02d:%02d:%02d', $datetime['year'], $datetime['month'], $datetime['day'], $datetime['hour'], $datetime['minute'], $datetime['second'] ); } |