public static function filter_month(\System\Database\Query $query, $val) { $date = new \DateTime($val); $date->modify('midnight'); $start = clone $date; $end = clone $date; $start->modify('first day of this month'); $end->modify('last day of this month')->modify('tomorrow'); $conds = array("start >= '" . $start->format('Y-m-d H:i:s') . "'", "start < '" . $end->format('Y-m-d H:i:s') . "'"); return $query->where($conds); }