本文整理汇总了PHP中Date_Calc::addMinutes方法的典型用法代码示例。如果您正苦于以下问题:PHP Date_Calc::addMinutes方法的具体用法?PHP Date_Calc::addMinutes怎么用?PHP Date_Calc::addMinutes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Date_Calc
的用法示例。
在下文中一共展示了Date_Calc::addMinutes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: round
//.........这里部分代码省略.........
$hn_year = $pn_year;
$hn_day = 0;
$hn_hour = 0;
$hn_minute = 0;
$hn_second = 0;
$hn_firstofmonth = Date_Calc::firstDayOfMonth($pn_month, $pn_year);
$hn_midmonth = (Date_Calc::lastDayOfMonth($pn_month, $pn_year) + 1 - $hn_firstofmonth) / 2;
if (($hn_days = Date_Calc::dateToDays($pn_day, $pn_month, $pn_year) - $hn_firstofmonth) <= $hn_midmonth - 1) {
$hn_month = $pn_month;
} else {
if ($hn_days >= $hn_midmonth) {
// Round up:
//
list($hn_year, $hn_month) = Date_Calc::nextMonth($pn_month, $pn_year);
} else {
// Take time into account:
//
$hn_partday = Date_Calc::secondsPastMidnight($pn_hour, $pn_minute, $pn_second) / 86400;
if ($hn_partday >= $hn_midmonth - $hn_days) {
// Round up:
//
list($hn_year, $hn_month) = Date_Calc::nextMonth($pn_month, $pn_year);
} else {
$hn_month = $pn_month;
}
}
}
} else {
if ($pn_precision == DATE_PRECISION_DAY) {
$hn_year = $pn_year;
$hn_month = $pn_month;
$hn_hour = 0;
$hn_minute = 0;
$hn_second = 0;
if (Date_Calc::secondsPastMidnight($pn_hour, $pn_minute, $pn_second) >= 43200) {
// Round up:
//
list($hn_year, $hn_month, $hn_day) = explode(" ", Date_Calc::nextDay($pn_day, $pn_month, $pn_year, "%Y %m %d"));
} else {
$hn_day = $pn_day;
}
} else {
if ($pn_precision == DATE_PRECISION_HOUR) {
$hn_year = $pn_year;
$hn_month = $pn_month;
$hn_day = $pn_day;
$hn_minute = 0;
$hn_second = 0;
if (Date_Calc::secondsPastTheHour($pn_minute, $pn_second) >= 1800) {
// Round up:
//
list($hn_year, $hn_month, $hn_day, $hn_hour) = Date_Calc::addHours(1, $pn_day, $pn_month, $pn_year, $pn_hour);
} else {
$hn_hour = $pn_hour;
}
} else {
if ($pn_precision <= DATE_PRECISION_MINUTE) {
$hn_year = $pn_year;
$hn_month = $pn_month;
$hn_day = $pn_day;
$hn_hour = $pn_hour;
$hn_second = 0;
if ($pn_precision < DATE_PRECISION_MINUTE) {
$hn_minute = round($pn_minute, $pn_precision - DATE_PRECISION_MINUTE);
} else {
// Check seconds:
//
if ($pn_second >= 30) {
// Round up:
//
list($hn_year, $hn_month, $hn_day, $hn_hour, $hn_minute) = Date_Calc::addMinutes(1, $pn_day, $pn_month, $pn_year, $pn_hour, $pn_minute);
} else {
$hn_minute = $pn_minute;
}
}
} else {
// Precision is at least (DATE_PRECISION_SECOND - 1):
//
$hn_year = $pn_year;
$hn_month = $pn_month;
$hn_day = $pn_day;
$hn_hour = $pn_hour;
$hn_minute = $pn_minute;
$hn_second = round($pn_second, $pn_precision - DATE_PRECISION_SECOND);
if (fmod($hn_second, 1) == 0.0) {
$hn_second = (int) $hn_second;
if ($hn_second != intval($pn_second)) {
list($hn_year, $hn_month, $hn_day, $hn_hour, $hn_minute, $hn_second) = Date_Calc::addSeconds($hn_second - intval($pn_second), $pn_day, $pn_month, $pn_year, $pn_hour, $pn_minute, intval($pn_second), $pn_precision >= DATE_PRECISION_SECOND && $pb_countleap);
//
// (N.B. if rounded to nearest 10 seconds,
// user does not expect seconds to be '60')
}
}
}
}
}
}
}
return array((int) $hn_year, (int) $hn_month, (int) $hn_day, (int) $hn_hour, (int) $hn_minute, $hn_second);
}
示例2: _addOffset
/**
* Add a time zone offset to the passed date/time
*
* @param int $pn_offset the offset to add in milliseconds
* @param int $pn_day the day
* @param int $pn_month the month
* @param int $pn_year the year
* @param int $pn_hour the hour
* @param int $pn_minute the minute
* @param int $pn_second the second
* @param float $pn_partsecond the part-second
*
* @return array array of year, month, day, hour, minute, second,
* and part-second
* @access private
* @static
* @since Method available since Release 1.5.0
*/
function _addOffset($pn_offset, $pn_day, $pn_month, $pn_year, $pn_hour, $pn_minute, $pn_second, $pn_partsecond)
{
if ($pn_offset == 0) {
return array((int) $pn_year, (int) $pn_month, (int) $pn_day, (int) $pn_hour, (int) $pn_minute, (int) $pn_second, (double) $pn_partsecond);
}
if ($pn_offset % 3600000 == 0) {
list($hn_year, $hn_month, $hn_day, $hn_hour) = Date_Calc::addHours($pn_offset / 3600000, $pn_day, $pn_month, $pn_year, $pn_hour);
$hn_minute = (int) $pn_minute;
$hn_second = (int) $pn_second;
$hn_partsecond = (double) $pn_partsecond;
} else {
if ($pn_offset % 60000 == 0) {
list($hn_year, $hn_month, $hn_day, $hn_hour, $hn_minute) = Date_Calc::addMinutes($pn_offset / 60000, $pn_day, $pn_month, $pn_year, $pn_hour, $pn_minute);
$hn_second = (int) $pn_second;
$hn_partsecond = (double) $pn_partsecond;
} else {
list($hn_year, $hn_month, $hn_day, $hn_hour, $hn_minute, $hn_secondraw) = Date_Calc::addSeconds($pn_offset / 1000, $pn_day, $pn_month, $pn_year, $pn_hour, $pn_partsecond == 0.0 ? $pn_second : $pn_second + $pn_partsecond, false);
// N.B. do not count
// leap seconds
if (is_float($hn_secondraw)) {
$hn_second = intval($hn_secondraw);
$hn_partsecond = $hn_secondraw - $hn_second;
} else {
$hn_second = $hn_secondraw;
$hn_partsecond = 0.0;
}
}
}
return array($hn_year, $hn_month, $hn_day, $hn_hour, $hn_minute, $hn_second, $hn_partsecond);
}