开发者

PHP get 4 months of dates using foreach

How would i get 4 months worth of dates from today using for each. I want to display the next 4 months of dates from today and format each one using foreach. Any 开发者_StackOverflow中文版ideas on how to do this.

Marvellous


$date = time();
$endDate = strtotime('+4 months');

while ($date < $endDate) {
    echo date('j/n/Y', $date).'<br />';
    $date += 86400; // 1 day
}


$ds = range(1,120);

foreach( $ds as $d){

echo date('Y-m-d', strtotime("today + $d day"));

}

This'll work if you are happy to guess that 4 months is 120 days away

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜