function computeWeek($date1,$date2){
$diff = abs(strtotime($date2) - strtotime($date1)); #取差集的绝对值
$week = floor($diff/(24*60*60*7)); #获取多少周
$day = ($diff%(24*60*60*7))/(24*60*60); #除周数以外的天数
$res = $week."周又".($day+1)."天";
return $res;
}
echo computeWeek("2011-06-06","2012-06-06")."<br>"; #52周又3天
echo computeWeek("2012-06-09","2012-06-01")."<br>"; #1周又2天
网友评论