Level 60
Easy
$date = new DateTime();
$monday = $date->modify('Monday this week')->format('Y-m-d');
$sunday = $date->modify('Sunday this week')->format('Y-m-d');
// or
$monday = Carbon::now()->startOfWeek();
$sunday = Carbon::now()->endOfWeek();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I know this forum is focus about laravel. I dont know where to ask this question.
Possible or not, I want to get two date by week . for example code:
$ddate = "2018-11-23";
$date = new DateTime($ddate);
$week = $date->format("W"); // 47 weeks
//output to get 2 dates from 47weeks
//2018-11-18 - 2018-11-24
Easy
$date = new DateTime();
$monday = $date->modify('Monday this week')->format('Y-m-d');
$sunday = $date->modify('Sunday this week')->format('Y-m-d');
// or
$monday = Carbon::now()->startOfWeek();
$sunday = Carbon::now()->endOfWeek();
Please or to participate in this conversation.