trafkjw
trafkjw

Reputation: 37

Print date and day name between 2 dates in Laravel blade

I am beginner in Laravel and PH{ I have this code:

$dateFrom = '2020-01-14';
$dateTo = '2020-02-19';

I need show date with day name (in Polish) between this dates.

I need result in this form:

2020-01-14 - Tuesday (Wtorek) 2020-01-15 - Wednesday (Środa)

How can I make it?

Upvotes: 0

Views: 280

Answers (1)

Foued MOUSSI
Foued MOUSSI

Reputation: 4813

//...
Carbon::setLocale('pl');
$period = CarbonPeriod::create('2020-01-14', '2020-02-19');

// Iterate over the period
foreach ($period as $date) {
    echo '(' . $date->format('l') . ')' . $date->format('Y-m-d');
}
//...

Upvotes: 2

Related Questions