本文整理汇总了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);
}
}