Home >php教程 >php手册 >All times between two dates

All times between two dates

大家讲道理
大家讲道理Original
2016-11-09 14:23:381458browse

function DateRange ($begin,$end,$interval='M'){
$begin = new DateTime($begin);
$end   = new DateTime($end);
$end = $end->modify('+1 day');
$t ='P1'.$interval;
$interval = new DateInterval($t);
$daterange = new DatePeriod($begin, $interval ,$end);

foreach($daterange as $date){
$range[]= $date->format("Ymd");
}
return $range;
}


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Related articles

See more