我如何通过在 laravel 中给出特定日期来获得周末日期?

How i can get weekend date by giving specific date in laravel?

我正在尝试获取 17-03-2021

的周末日期

目前正在获取本周的周末日期,我想在特定日期之前获取。

Carbon::now()->endOfWeek()->format('d-m-Y')

如果 Carbon::now()->endOfWeek()->format('d-m-Y') 正在做你想做的事情,只是没有特定日期,那么解析你想要作为基础的日期:

Carbon::parse('17-03-2021')->endOfWeek()->format('d-m-Y')

也考虑 ->nextWeekendDay()->previousWeekendDay() 作为周末的方式。