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.
Wireframe for restaurant menu
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);
Source: https://carbon.nesbot.com/docs/#api-getters
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With