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
精彩评论