I am working with Laravel 4 on a tool to publish/schedule restaurant menus on facebook. For this I need a date selector for the current week, starting always on monday and ending always on sunday.
I'have played around with the examples http://carbon.nesbot.com/docs/#api-getters but without success.
Any idea?
This is pretty simple with Carbon Library. Here is the code example:
$now = Carbon::now();
$weekStartDate = $now->startOfWeek()->format('Y-m-d H:i');
$weekEndDate = $now->endOfWeek()->format('Y-m-d H:i');
Even you have the option to change start and end day of the week. It is like this,
$start = $now->startOfWeek(Carbon::TUESDAY);
$end = $now->endOfWeek(Carbon::MONDAY);