本文整理汇总了PHP中date::hours方法的典型用法代码示例。如果您正苦于以下问题:PHP date::hours方法的具体用法?PHP date::hours怎么用?PHP date::hours使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类date
的用法示例。
在下文中一共展示了date::hours方法的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: months
/**
* Number of months in a year
*
* @return array A mirrored (foo => foo) array from 1-12.
*/
public static function months()
{
return date::hours();
}