/** * 建立一个包含指定范围单元的数组 */ public static function range($start, $end, $split = 1) { return array_range($start, $end, $split); }
/** * Cria um conjunto de caixa de seleção para a data. * * @param string $name Nome do conjunto de caixas de seleção * @param array $options Opções das caixas de seleção * @return string Conjunto de caixa de seleção */ public function date($name, $options = array()) { if (!is_null($options["value"])) { $date = strtotime($options["value"]); } else { $date = time(); } $options = array_merge(array("value" => null, "startYear" => 1980, "endYear" => date("Y"), "currentDay" => date("j", $date), "currentMonth" => date("n", $date), "currentYear" => date("Y", $date)), $options); $days = array_range(1, 31); $months = array_range(1, 12); $years = array_range($options["startYear"], $options["endYear"]); $selectDay = $this->select($name . "[d]", array("value" => $options["currentDay"], "options" => $days, "id" => $options["id"] . "D")); $selectMonth = $this->select($name . "[m]", array("value" => $options["currentMonth"], "options" => $months, "id" => $options["id"] . "M")); $selectYear = $this->select($name . "[y]", array("value" => $options["currentYear"], "options" => $years, "id" => $options["id"] . "Y")); return $this->output($selectDay . $selectMonth . $selectYear); }
public function date($name, $options = array()) { if (is_array($options['value'])) { $date = mktime(0, 0, 0, $v['m'], $v['d'], $v['y']); } elseif (!is_null($options['value'])) { $date = strtotime($options['value']); } else { $date = time(); } $options += array('value' => null, 'startYear' => 1980, 'endYear' => date('Y'), 'currentDay' => date('j', $date), 'currentMonth' => date('n', $date), 'currentYear' => date('Y', $date), 'format' => 'dmy'); $days = array_range(1, 31); $months = array_range(1, 12); $years = array_range($options['startYear'], $options['endYear']); $select_day = $this->select($name . '[d]', array('value' => $options['currentDay'], 'options' => $days, 'id' => $options['id'] . 'D')); $select_month = $this->select($name . '[m]', array('value' => $options['currentMonth'], 'options' => $months, 'id' => $options['id'] . 'M')); $select_year = $this->select($name . '[y]', array('value' => $options['currentYear'], 'options' => $years, 'id' => $options['id'] . 'Y')); if ($format == 'ymd') { return $select_year . $select_month . $select_day; } else { return $select_day . $select_month . $select_year; } }