Updated June 2026. Tested on Laravel 13 and PHP 8.4.

Sometimes you need every individual date between two dates, for example to build a timesheet or a payroll sheet where each day is a column. Carbon, which ships with Laravel, makes this a one liner with CarbonPeriod.

The clean way: CarbonPeriod

use Carbon\CarbonPeriod;

$dates = CarbonPeriod::create('2026-01-01', '2026-01-31');

foreach ($dates as $date) {
    echo $date->toDateString();   // 2026-01-01, 2026-01-02, ...
}

CarbonPeriod walks day by day from the start to the end, inclusive. To collect them into an array of strings:

$all = collect(CarbonPeriod::create('2026-01-01', '2026-01-31'))
    ->map(fn ($date) => $date->toDateString())
    ->all();

Stepping by something other than a day

CarbonPeriod is not limited to days. Pass an interval to step by weeks, or every two days, or any unit.

// every Monday in the range
$weeks = CarbonPeriod::create('2026-01-01', '1 week', '2026-03-31');

// every 2 days
$everyOther = CarbonPeriod::create('2026-01-01', '2 days', '2026-01-31');

The manual loop, for reference

Before CarbonPeriod you would write a while loop, adding a day each pass until you reach the end. It still works and is worth knowing.

use Carbon\Carbon;

$start = Carbon::parse('2026-01-01');
$end   = Carbon::parse('2026-01-31');
$all   = [];

while ($start->lte($end)) {
    $all[] = $start->toDateString();
    $start->addDay();
}

lte means less than or equal, so the loop includes the end date. But CarbonPeriod is shorter and clearer, so reach for that first. For more on Carbon itself, see the post on working with dates in Laravel. Questions welcome in the comments.