I am beginner in Laravel. I use in my project Laravel 5.8.
I have this code:
$userPromotionDays = $user->premiumDate; // 2019.08.28 $daysToAdd = 5
How can I add $userPromotionDays to $daysToAdd (in Laravel/Carbon)?
Advertisement
Answer
You can create date with custom format and then add days to it using carbon.
$date = Carbon::createFromFormat('Y.m.d', $user->premiumDate); $daysToAdd = 5; $date = $date->addDays($daysToAdd); dd($date);
You can see details documentation here.