當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DateHelper::month_array方法代碼示例

本文整理匯總了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";
 }
開發者ID:awotherspoon-score,項目名稱:IC,代碼行數:18,代碼來源:albummapper.php

示例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;
 }
開發者ID:awotherspoon-score,項目名稱:IC,代碼行數:34,代碼來源:newseventmapper.php


注:本文中的DateHelper::month_array方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。