Issue
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)?
Solution
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.
Answered By - Rahul
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.