php获取两个日期的之间的日期信息,返回数组
/**
* 获取两个日期的之间的日期信息,返回数组
*
* @param string $startDate
* @param string $endDate
* @return array
*/
private function periodDate(string $startDate, string $endDate): array
{
$startDate = strtotime($startDate);
$endDate = strtotime($endDate);
$i = 0;
$arr = [];
while ($startDate <= $endDate) {
$arr[$i] = date('Y-m-d', $startDate);
$startDate = strtotime('+1 day', $startDate);
$i++;
}
return $arr; // ['2021-01-01', '2021-01-02']
}
本文来自博客园,作者:alisleepy,转载请注明原文链接:https://www.cnblogs.com/alisleepy/p/14861431.html