Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Laracast13's avatar

Laravel date add days

Hello

In balade showing data type field {{$product->date}} which showing 2022-02-22 I add + 5 day and show 2022-02-27

0 likes
6 replies
Niush's avatar
{{ now($product->date)->addDays(5) }}
1 like
Niush's avatar
Niush
Best Answer
Level 50

@www888

The date column is not correctly stored so the value is invalid date string. You can try by parsing like this:

{{ now()->parse($product->date)->addDays(5) }}

Or, better you can add cast in the Product Model.

protected $casts = [
    'date' => 'datetime:Y-m-d',
];
1 like
Laracast13's avatar

@Niush This works

{{ now()->parse($product->date)->addDays(5) }} 

2022-06-29 00:00:00 how remove 00:00:00

Laracast13's avatar

Fixed {{ date('Y-m-d', strtotime(now()->parse($product->date)->addDays(5))) }}

Please or to participate in this conversation.