Skip to content
Advertisement

How can I get date day by day?

I’m beginner in PHP and I’m trying to learn. I want to get the date of the next four days in Laravel. I tried like this but it returns the date four days later.

$days = date('Y-m-d', strtotime(' +4 day'));

I want to take all the next four days. How can I show all the next four days in the blade?

Advertisement

Answer

I hope this will help you out

$days = [];

for ($i = 0; $i <= 4; $i++) {
    $days[] = date("D", strtotime("$i day"));
}

var_dump($days);
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement