获取某个时间段内,每个几天的日期
作者:
云龙789 | 来源:发表于
2019-02-26 14:46 被阅读3次
<?php
$dateStart = new \DateTime();
$dateInterval = \DateInterval::createFromDateString('-2 days');
$datePeriod = new \DatePeriod($dateStart,$dateInterval,30);
foreach ($datePeriod as $date){
echo $date->format('Y-m-d');
echo '<br>';
}
$begin = new DateTime( '2012-08-01' );
$interval = new DateInterval('P2D');
$daterange = new DatePeriod($begin, $interval ,15);
foreach($daterange as $date){
echo $date->format("Y-m-d") . "<br>";
}
image.png
本文标题:获取某个时间段内,每个几天的日期
本文链接:https://www.haomeiwen.com/subject/iwmayqtx.html
网友评论