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


PHP Date_Calc::addMonths方法代碼示例

本文整理匯總了PHP中Date_Calc::addMonths方法的典型用法代碼示例。如果您正苦於以下問題:PHP Date_Calc::addMonths方法的具體用法?PHP Date_Calc::addMonths怎麽用?PHP Date_Calc::addMonths使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Date_Calc的用法示例。


在下文中一共展示了Date_Calc::addMonths方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: addMonths

 /**
  * Converts the date to the specified no of months from the given date
  *
  * To subtract months use a negative value for the '$pn_months'
  * parameter
  *
  * @param int $pn_months months to add
  *
  * @return   void
  * @access   public
  * @since    Method available since Release 1.5.0
  */
 function addMonths($pn_months)
 {
     list($hs_year, $hs_month, $hs_day) = explode(" ", Date_Calc::addMonths($pn_months, $this->day, $this->month, $this->year, "%Y %m %d"));
     $this->setLocalTime($hs_day, $hs_month, $hs_year, $this->hour, $this->minute, $this->second, $this->partsecond);
 }
開發者ID:,項目名稱:,代碼行數:17,代碼來源:

示例2: beginOfMonthBySpan

 /**
  * Returns date of the first day of the month in the number of months
  * from the given date
  *
  * @param int    $months the number of months from the date provided.
  *                        Positive numbers go into the future.
  *                        Negative numbers go into the past.
  *                        0 is the month presented in $month.
  * @param string $month  the month, default is current local month
  * @param string $year   the year in four digit format, default is the
  *                        current local year
  * @param string $format the string indicating how to format the output
  *
  * @return   string     the date in the desired format
  * @access   public
  * @static
  * @since    Method available since Release 1.4.4
  */
 function beginOfMonthBySpan($months = 0, $month = 0, $year = null, $format = DATE_CALC_FORMAT)
 {
     if (is_null($year)) {
         $year = Date_Calc::dateNow('%Y');
     }
     if (empty($month)) {
         $month = Date_Calc::dateNow('%m');
     }
     return Date_Calc::addMonths($months, Date_Calc::getFirstDayOfMonth($month, $year), $month, $year, $format);
 }
開發者ID:222elm,項目名稱:dotprojectFrame,代碼行數:28,代碼來源:Calc.php

示例3: monthlySchedule

 /**
  * Returns an array of dates for a monthly schedule (like subscription)
  * @param $startDate date('Y-m-d')
  * @param int number of months
  * @param bool (optional, default true) include start date in the schedule
  */
 public static function monthlySchedule($startDate, $num, $inclstart = true)
 {
     $startTime = strtotime($startDate);
     $startDay = date('d', $startTime);
     $startMonth = date('m', $startTime);
     $startYear = date('Y', $startTime);
     $startoffset = $inclstart ? 0 : 1;
     for ($i = $startoffset; $i < $num; $i++) {
         $dt[] = Date_Calc::addMonths($i, $startDay, $startMonth, $startYear, '%Y-%m-%d');
         // Correcting not valid dates (e.g. february 30, june 31)
         /*       $tempdt = date('d',strtotime($dt[$i]));
                $numd = date('t',strtotime($dt[$i]));
                if($tempdt>$numd) {
                  $dt[$i] = date('Y',strtotime($dt[$i])).'-'.date('m',strtotime($dt[$i])).'-'.$numd;
                }*/
     }
     return $dt;
 }
開發者ID:demental,項目名稱:m,代碼行數:24,代碼來源:Calc.php


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