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


PHP Date_Calc::addDays方法代碼示例

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


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

示例1: nextDay

 /**
  * Returns date of day after given date
  *
  * @param int    $day    the day of the month, default is current local day
  * @param int    $month  the month, default is current local month
  * @param int    $year   the year in four digit format, default is 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
  */
 function nextDay($day = 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');
     }
     if (empty($day)) {
         $day = Date_Calc::dateNow('%d');
     }
     return Date_Calc::addDays(1, $day, $month, $year, $format);
 }
開發者ID:222elm,項目名稱:dotprojectFrame,代碼行數:26,代碼來源:Calc.php

示例2: subtractSpan

 /**
  * Subtracts a time span from the date
  *
  * N.B. it is impossible for this function to count leap seconds,
  * because the result would be dependent on which order the consituent
  * parts of the span are subtracted from the date.  Therefore, leap
  * seconds are ignored by this function.  If you want to count leap
  * seconds, use 'subtractSeconds()'.
  *
  * @param object $span the time span to subtract
  *
  * @return   void
  * @access   public
  */
 function subtractSpan($span)
 {
     if (!is_a($span, 'Date_Span')) {
         return PEAR::raiseError("Invalid argument - not 'Date_Span' object");
     } else {
         if ($this->ob_invalidtime) {
             return $this->_getErrorInvalidTime();
         }
     }
     $hn_days = -$span->day;
     $hn_standardhour = $this->on_standardhour - $span->hour;
     $hn_standardminute = $this->on_standardminute - $span->minute;
     $hn_standardsecond = $this->on_standardsecond - $span->second;
     if ($hn_standardsecond < 0) {
         --$hn_standardminute;
         $hn_standardsecond += 60;
     }
     if ($hn_standardminute < 0) {
         --$hn_standardhour;
         $hn_standardminute += 60;
     }
     if ($hn_standardhour < 0) {
         --$hn_days;
         $hn_standardhour += 24;
     }
     list($hn_standardyear, $hn_standardmonth, $hn_standardday) = explode(" ", Date_Calc::addDays($hn_days, $this->on_standardday, $this->on_standardmonth, $this->on_standardyear, "%Y %m %d"));
     $this->setStandardTime($hn_standardday, $hn_standardmonth, $hn_standardyear, $hn_standardhour, $hn_standardminute, $hn_standardsecond, $this->on_standardpartsecond);
 }
開發者ID:,項目名稱:,代碼行數:42,代碼來源:


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