$students = array(); foreach ($sections as $section) { foreach ($section['students'] as $student) { $students[] = $student['id']; } } $response = $sql->query("\n\tSELECT *\n\t\tFROM `due_dates` as `d`\n\t\t\tLEFT JOIN `assessments` as `a` ON `d`.`assignment` = `a`.`id`\n\t\tWHERE\n\t\t\t(`d`.`student` = '" . implode("' OR `d`.`student` = '", $students) . "')\n\t\t\tAND (`a`.`course` != '{$courseId}'\n\t\tORDER BY\n\t\t\t`d`.`due` ASC\n"); $assessments = array(); $dueDates = array(); while ($dueDate = $response->fetch_assoc()) { if (empty($assessments[$dueDate['assignment']])) { $assessments[$dueDate['assignment']] = unserialize($dueDate['a.data']); } $dueDates[] = array('student' => $dueDate['student']); } /* build a month grid */ $month = empty($_REQUEST['month']) ? date('m') : $_REQUEST['month']; $year = empty($_REQUEST['year']) ? date('Y') : $_REQUEST['year']; $grid = array(); $week = 0; for ($day = 1; $day <= date('t', strtotime("{$year}-{$month}-01")); $i++) { $day2 = (strlen($day) == 1 ? '0' : '') . $day; $dayOfWeek = date('w', strotime("{$year}-{$month}-{$day2}")); $grid[$week][$dayOfWeek] = date("Y-m-d", strtotime("{$year}-{$month}-{$day2}")); if ($dayOfWeek == 6) { $week++; } } $smarty->assign('grid', $grid); $smarty->assign('assessments', $assessments); $smarty->display('assessment-calendar.tpl');
/** * Get the modification date for the last modified post in the post type: * * @param array $post_types Post types to get the last modification date for * * @return string */ function get_last_modified($post_types) { global $wpdb; if (!is_array($post_types)) { $post_types = array($post_types); } // We need to do this only once, as otherwise we'd be doing a query for each post type if (!is_array($this->post_type_dates)) { $this->post_type_dates = array(); $query = "SELECT post_type, MAX(post_modified_gmt) AS date FROM {$wpdb->posts} WHERE post_status IN ('publish','inherit') AND post_type IN ('" . implode("','", get_post_types(array('public' => true))) . "') GROUP BY post_type ORDER BY post_modified_gmt DESC"; $results = $wpdb->get_results($query); foreach ($results as $obj) { $this->post_type_dates[$obj->post_type] = $obj->date; } unset($results); } if (count($post_types) === 1) { $result = strtotime($this->post_type_dates[$post_types[0]]); } else { $result = 0; foreach ($post_types as $post_type) { if (strotime($this->post_type_dates[$post_type]) > $result) { $result = strtotime($this->post_type_dates[$post_type]); } } } return date('c', $result); }
<?php // $random = rand(1, 100); // echo "your new random value is " . $random . "\n"; date_default_timezone_set(); $days = 30; $month = date_create('2015-01-01'); $months = date_add($month, strotime($days)); echo $months->format('Y-m-d') . "\n";