/**
* 期间日期
* @param $startDate
* @param $endDate
* @return array
*/
function periodDate($startDate, $endDate){
$startTime = strtotime($startDate);
$endTime = strtotime($endDate);
$arr = array();
while ($startTime <= $endTime){
$arr[] = date('Y-m-d', $startTime);
$startTime = strtotime('+1 day', $startTime);
}
return $arr;
}
// 获取期间所有日期
$dateArr = periodDate('2020-03-01','2020-03-03');
// 返回结果
array(3) {
[0]=>
string(10) "2020-03-01"
[1]=>
string(10) "2020-03-02"
[2]=>
string(10) "2020-03-03"
}
/**
* 返回期间日期和对应后一天日期二维数组
* @param $startDate
* @param $endDate
* @return array
*/
function periodDate($startDate, $endDate){
$startTime = strtotime($startDate);
$endTime = strtotime($endDate);
$arr = array();
while ($startTime <= $endTime){
$arr[] = array(
date('Y-m-d', $startTime),
date('Y-m-d', strtotime('+1 day', $startTime))
);
$startTime = strtotime('+1 day', $startTime);
}
return $arr;
}
// 获取期间所有日期
$dateArr = periodDate('2020-03-01','2020-03-03');
// 返回结果
array(3) {
[0]=>
array(2) {
[0]=>
string(10) "2020-03-01"
[1]=>
string(10) "2020-03-02"
}
[1]=>
array(2) {
[0]=>
string(10) "2020-03-02"
[1]=>
string(10) "2020-03-03"
}
[2]=>
array(2) {
[0]=>
string(10) "2020-03-03"
[1]=>
string(10) "2020-03-04"
}
}