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


PHP Date_Calc::secondsPastMidnightToTime方法代碼示例

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


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

示例1: addSeconds


//.........這裏部分代碼省略.........
             // Go back to start of month:
             //
             if ($hn_secondsofmonth != 0 && -$hn_seconds >= $hn_secondsofmonth) {
                 $hn_seconds += $hn_secondsofmonth;
                 $hn_secondsofmonth = 0;
                 $hn_day = Date_Calc::getFirstDayOfMonth($hn_month, $hn_year);
                 $hn_hour = $hn_minute = $hn_second = 0;
             }
             // Go back to start of year:
             //
             if ($hn_secondsofmonth == 0) {
                 while ($hn_month != Date_Calc::getFirstMonthOfYear($hn_year)) {
                     list($hn_year, $hn_prevmonth) = Date_Calc::prevMonth($hn_month, $hn_year);
                     if (-$hn_seconds >= ($hn_secondsinmonth = Date_Calc::getSecondsInMonth($hn_prevmonth, $hn_year))) {
                         $hn_seconds += $hn_secondsinmonth;
                         $hn_month = $hn_prevmonth;
                         $hn_day = Date_Calc::getFirstDayOfMonth($hn_month, $hn_year);
                     } else {
                         break;
                     }
                 }
             }
             if ($hn_secondsofmonth == 0) {
                 // Subtract years:
                 //
                 if ($hn_month == Date_Calc::getFirstMonthOfYear($hn_year)) {
                     while (-$hn_seconds >= ($hn_secondsinyear = Date_Calc::getSecondsInYear($hn_year - 1))) {
                         $hn_seconds += $hn_secondsinyear;
                         $hn_month = Date_Calc::getFirstMonthOfYear(--$hn_year);
                         $hn_day = Date_Calc::getFirstDayOfMonth($hn_month, $hn_year);
                     }
                 }
                 // Subtract months:
                 //
                 list($hn_pmyear, $hn_prevmonth) = Date_Calc::prevMonth($hn_month, $hn_year);
                 while (-$hn_seconds >= ($hn_secondsinmonth = Date_Calc::getSecondsInMonth($hn_prevmonth, $hn_pmyear))) {
                     $hn_seconds += $hn_secondsinmonth;
                     $hn_year = $hn_pmyear;
                     $hn_month = $hn_prevmonth;
                     $hn_day = Date_Calc::getFirstDayOfMonth($hn_month, $hn_year);
                     list($hn_pmyear, $hn_prevmonth) = Date_Calc::prevMonth($hn_month, $hn_year);
                 }
             }
         }
         if ($hn_seconds < 0 && $hn_secondsofmonth == 0) {
             list($hn_year, $hn_month) = Date_Calc::prevMonth($hn_month, $hn_year);
             $hn_day = Date_Calc::getFirstDayOfMonth($hn_month, $hn_year);
             $hn_seconds += Date_Calc::getSecondsInMonth($hn_month, $hn_year);
         }
         $hn_seconds += Date_Calc::secondsPastMidnight($hn_hour, $hn_minute, $hn_second);
         if ($hn_seconds < 0) {
             $hn_daysadd = intval($hn_seconds / 86400) - 1;
         } else {
             if ($hn_seconds < 86400) {
                 $hn_daysadd = 0;
             } else {
                 $hn_daysadd = intval($hn_seconds / 86400) - 1;
             }
         }
         if ($hn_daysadd != 0) {
             list($hn_year, $hn_month, $hn_day) = explode(" ", Date_Calc::addDays($hn_daysadd, $hn_day, $hn_month, $hn_year, "%Y %m %d"));
             $hn_seconds -= $hn_daysadd * 86400;
         }
         $hn_secondsinday = Date_Calc::getSecondsInDay($hn_day, $hn_month, $hn_year);
         if ($hn_seconds >= $hn_secondsinday) {
             list($hn_year, $hn_month, $hn_day) = explode(" ", Date_Calc::addDays(1, $hn_day, $hn_month, $hn_year, "%Y %m %d"));
             $hn_seconds -= $hn_secondsinday;
         }
         list($hn_hour, $hn_minute, $hn_second) = Date_Calc::secondsPastMidnightToTime($hn_seconds);
         return array((int) $hn_year, (int) $hn_month, (int) $hn_day, $hn_hour, $hn_minute, $hn_second);
     } else {
         // Assume every day has 86400 seconds exactly (ignore leap seconds):
         //
         $hn_minutes = intval($pn_seconds / 60);
         if (is_float($pn_seconds)) {
             $hn_second = $pn_second + fmod($pn_seconds, 60);
         } else {
             $hn_second = $pn_second + $pn_seconds % 60;
         }
         if ($hn_second >= 60) {
             ++$hn_minutes;
             $hn_second -= 60;
         } else {
             if ($hn_second < 0) {
                 --$hn_minutes;
                 $hn_second += 60;
             }
         }
         if ($hn_minutes == 0) {
             $hn_year = $pn_year;
             $hn_month = $pn_month;
             $hn_day = $pn_day;
             $hn_hour = $pn_hour;
             $hn_minute = $pn_minute;
         } else {
             list($hn_year, $hn_month, $hn_day, $hn_hour, $hn_minute) = Date_Calc::addMinutes($hn_minutes, $pn_day, $pn_month, $pn_year, $pn_hour, $pn_minute);
         }
         return array($hn_year, $hn_month, $hn_day, $hn_hour, $hn_minute, $hn_second);
     }
 }
開發者ID:222elm,項目名稱:dotprojectFrame,代碼行數:101,代碼來源:Calc.php


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