两个日期相差的天数

$Date_1 = date("Y-m-d");  
$Date_2 = "2018-8-20";  
$d1 = strtotime($Date_1);  
$d2 = strtotime($Date_2);  
$Days = ($d2-$d1)/3600/24;  
echo "相差" . $Days . "天"; 



function prDates($start,$end){ // 两个日期之间的所有日期  
    $dt_start = strtotime($start);  
    $dt_end = strtotime($end);  
    while ($dt_start<=$dt_end){  
        echo date('Y-m-d',$dt_start)."\n";  
        $dt_start = strtotime('+1 day',$dt_start);  
    }  
}  
prDates('2005-02-01','2005-02-05'); 

猜你喜欢

转载自www.cnblogs.com/zjj1990/p/9564195.html