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

All times between two dates

大家讲道理
Release: 2016-11-09 14:23:38
Original
1424 people have browsed it

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;
}
Copy after login


source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template