php计算指定时间段内的天数

 

 

private function _getCountDays($sTime, $eTime)
{
    $startDt = getdate($sTime);
    $endDt = getdate($eTime);
    $sUTime = mktime(12, 0, 0, $startDt['mon'], $startDt['mday'], $startDt['year']);
    $eUTime = mktime(12, 0, 0, $endDt['mon'], $endDt['mday'], $endDt['year']);
    return round(abs($sUTime - $eUTime) / 86400);
}

$sTime = strtotime('2011-01-01');
$eTime = strtotime('2011-01-22');

 

 

 

 

 

你可能感兴趣的:(PHP)