Khirad Zahra
Khirad Zahra

Reputation: 893

Get coming day from any given date with Carbon

How can i get the next Sunday from the given date with Carbon,Like i want to get he next Sunday from this date.

2017-04-03 which would be 2017-04-09,

I can get coming Sunday from new Carbon('next sunday'); ,but i need to get it from specific date.

Any help will be highly appreciated.

Upvotes: 1

Views: 1228

Answers (1)

Alexey Mezenin
Alexey Mezenin

Reputation: 163748

One way to do this:

Carbon::parse($someDate)->endOfWeek()

You can also chain ->startOfDay() if time part is important.

Or you can do this:

Cabon::parse($someDate)->startOfWeek()->addDays(6)

Upvotes: 1

Related Questions