Ramadhani Pratama
Ramadhani Pratama

Reputation: 71

How to display date in PHP?

If date now is 2015-08-15. How to display the result like this:

2015-08-15

2015-08-16

2015-08-17

I have the following code:

$today = date('Y-m-d');
$a = "3";
$nextDate = date('Y-m-d', strtotime($today . ' + ' . $a . ' days'));

echo $nextDate;

Upvotes: 0

Views: 69

Answers (1)

Danila Ganchar
Danila Ganchar

Reputation: 11223

$date = new DateTime();

echo $date->format('Y-m-d') . '<br/>';

for ($i = 1; $i < 3; $i++) {
    $date->modify('+1 day');
    echo $date->format('Y-m-d') . '<br/>';
}

Upvotes: 1

Related Questions