Exemple #1
0
 public function test_build_mysql_datetime_default_to_max_default_to_false()
 {
     $q = new WP_Date_Query(array());
     $found = $q->build_mysql_datetime(array('year' => 2011), false);
     $this->assertSame('2011-01-01 00:00:00', $found);
 }
 public function date_query($args = array())
 {
     if (!isset($args['date_query'])) {
         return false;
     }
     $queries = new WP_Date_Query(array());
     $date_query = $queries->sanitize_query($args['date_query']);
     if (!$queries->validate_date_values($date_query)) {
         return false;
     }
     //current time
     $this->current_time = (int) current_time('timestamp');
     if (isset($date_query['after'])) {
         $target = $date_query['after'];
     }
     if (isset($date_query['before'])) {
         $target = $date_query['before'];
     }
     //format time to strtotime
     $this->date_sql = $queries->build_mysql_datetime($target, $default_to_max = false);
     //after time target
     $this->date_strtotime = strtotime($this->date_sql, $this->current_time);
 }