本文整理汇总了PHP中DateHelper::month_array方法的典型用法代码示例。如果您正苦于以下问题:PHP DateHelper::month_array方法的具体用法?PHP DateHelper::month_array怎么用?PHP DateHelper::month_array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateHelper
的用法示例。
在下文中一共展示了DateHelper::month_array方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: selectLiveAlbumsForPeriodQuery
public function selectLiveAlbumsForPeriodQuery($period)
{
//echo $period;
$dh = new DateHelper();
$month_array = $dh->month_array();
if (array_key_exists($period, $month_array)) {
//period is a month e.g. 'january' | 'february' etc
$month = $month_array[$period];
$year = $month > date('n') ? date('Y') - 1 : date('Y');
$start = mktime(0, 0, 0, $month, 1, $year);
$end = mktime(0, 0, 0, $month + 1, 0, $year);
} else {
//period is a year e.g. '2009' | '1964'
$start = mktime(0, 0, 0, 1, 1, $period);
$end = mktime(0, 0, 0, 1, 0, $period + 1);
}
return "SELECT * FROM albums WHERE status=" . Content::STATUS_LIVE . " AND datedisplayed BETWEEN {$start} AND {$end}" . " ORDER BY datedisplayed DESC";
}
示例2: periodToStartEndValues
private function periodToStartEndValues($period, $mode = 'news')
{
$boundary['start'] = 0;
$boundary['end'] = 0;
$period = strtolower($period);
//in case some genius sends us a capitalized month
$date_helper = new DateHelper();
$month_array = $date_helper->month_array();
if (array_key_exists($period, $month_array)) {
//$period contains a month
$month = $month_array[$period];
switch ($mode) {
case 'news':
$year = $month > date('n') ? date('Y') - 1 : date('Y');
break;
case 'events':
$year = $month < date('n') ? date('Y') + 1 : date('Y');
break;
}
$start = mktime(0, 0, 0, $month, 0, $year);
$end = mktime(0, 0, 0, $month + 1, 0, $year);
} elseif (preg_match('/[0-9]{4}/', $period) !== 0) {
//$period contains a 4-digit year
$year = $period;
$start = mktime(0, 0, 0, 1, 1, $year);
$end = mktime(0, 0, 0, 0, 0, $year + 1);
} else {
//bad $period value
throw new Exception('Bad $period Value passed: ' . $period);
}
$boundary['start'] = $start;
$boundary['end'] = $end;
return $boundary;
}