Add days to date in Laravel
Stefan Izdrail
Founder & Senior Architect · 2026-06-29
Title: Adding Days to Dates in Laravel Using Carbon
As a beginner in Laravel, you may come across situations where you need to manipulate dates in your applications. One such common task is adding days to a given date. In this blog post, we will provide a thorough answer and relevant code examples for effectively handling date arithmetic using the Laravel Carbon package.
Understanding Carbon
Carbon is a PHP library that simplifies working with dates and time in your applications. It comes as part of the Laravel framework and offers an expressive API for manipulating dates and times. By default, PHP provides basic date functions but lacks comprehensive support for time zones and other advanced features. Carbon helps you overcome this limitation by providing a powerful toolset to work with dates and times in your code.Adding Days to Dates
To add days to a given date, you can use the addDays() method provided by Laravel's Carbon package. In your example, you have two variables: $userPromotionDays and $daysToAdd. To accomplish the desired task, follow these steps: 1. Create an instance of the Carbon date object using the given date from $userPromotionDays with the Carbon::parse() method. 2. Add the specified number of days to this date, which is already in Carbon format, using addDays(). 3. Output the result for verification. Here's an example code snippet:$userPromotionDays = Carbon::parse($user->premiumDate); // 2019-08-28
$daysToAdd = 5
$newPromotionDate = $userPromotionDays->addDays($daysToAdd);
// Output the new date with formatted output
echo $newPromotionDate->format('Y-m-d');
This example adds 5 days to the given date and outputs it in a formatted way. The result would be: "2019-09-02".