本文整理汇总了PHP中date::months方法的典型用法代码示例。如果您正苦于以下问题:PHP date::months方法的具体用法?PHP date::months怎么用?PHP date::months使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类date
的用法示例。
在下文中一共展示了date::months方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: date_dropdown
/**
* Creates a group of dropdown boxes for date selection
*
* @param string comma seperated list of parts to be included
* @param string form element name prefix example: user_
* @param array variables to be used within the function
* @return string html for specified elements
*/
public static function date_dropdown($parts = 'month,day,year,time', $prefix = '', $other = array(), $selected = array())
{
if (!is_array($parts)) {
$parts = explode(',', $parts);
}
// Blank HTML string.
$html = '';
foreach ($parts as $part) {
switch ($part) {
case 'month':
if (!isset($selected['month'])) {
$selected['month'] = date('n');
}
$html .= form::dropdown($prefix . 'month', date::months(), $selected['month']);
break;
case 'day':
if (!isset($selected['month'])) {
$selected['day'] = date('j');
}
$html .= form::dropdown($prefix . 'day', date::days(date('n')), $selected['day']);
break;
case 'year':
if (!isset($selected['year'])) {
$selected['year'] = date('Y');
}
if (!isset($other['year']['start'])) {
$other['year']['start'] = false;
}
if (!isset($other['year']['end'])) {
$other['year']['end'] = false;
}
$html .= form::dropdown($prefix . 'year', date::years($other['year']['start'], $other['year']['end']), $selected['year']);
break;
case 'time':
if (!isset($selected['hour'])) {
$selected['hour'] = date('g');
}
$html .= form::dropdown($prefix . 'hour', date::hours(), $selected['hour']);
if (!isset($selected['min'])) {
$selected['min'] = date('i');
}
$html .= form::dropdown($prefix . 'min', date::minutes(1), $selected['min']);
if (!isset($selected['ampm'])) {
$selected['ampm'] = date('a');
}
$html .= form::dropdown($prefix . 'ampm', array('am' => 'am', 'pm' => 'pm'), $selected['ampm']);
}
}
return $html;
}
示例2: array
echo form::select($field, $values, $value, $attributes);
break;
case 'select':
$values = @$fieldData['values'];
if (!$values) {
$values = array();
}
$values[-1] = "";
asort($values);
//$attributes['class'] .= ' block';
echo form::select($field, $values, $value, $attributes);
break;
case 'date':
$months[-1] = '';
### Generate list of years
foreach (date::months() as $month) {
$months[$month] = __('calendar.' . strtolower(date('F', mktime(0, 0, 0, $month, 1))));
}
$year = '';
$month = '';
$day = '';
/* Deal with cases where we feed in a UNIX timestamp value instead - Steve does this a lot (feed DB rows directly in as_array) */
if ($value && is_numeric($value)) {
$year = date('Y', $value);
$month = date('n', $value);
$day = date('d', $value);
} else {
if ($value && $value != '0000-00-00') {
$date = strtotime($value);
$year = date('Y', $date);
$month = date('n', $date);