php 日期

获取两个日期之间的间隔天列表:

$begin = new DateTime( '2012-08-0' );
$end = new DateTime( '2012-08-31' );
$end = $end->modify( '+1 day' );
$interval = new DateInterval('P1D');
$daterange = new DatePeriod($begin, $interval ,$end);

foreach($daterange as $date){
    echo $date->format("Ymd") . "<br>";
}

日期间隔月份:

$begin = new DateTime( '2012-08-01' );
$end = new DateTime( '2013-05-31' );
$end = $end->modify( '+1 month' );
$interval = new DateInterval('P1M');
$daterange = new DatePeriod($begin, $interval ,$end);

foreach($daterange as $date){
    echo $date->format("Ym") . "<br>";
}

上一篇:win10 搭建 npm 环境


下一篇:Failure to find xxx in xxx was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced @ xxx