3v4l.org

run code in 500+ PHP versions simultaneously
<?php date_default_timezone_set('UTC'); $dto = new DateTime('2024-01-30 23:01:00'); $dto->setISODate(2024, 1); $fmt = new IntlDateFormatter('de_DE', IntlDateFormatter::NONE, IntlDateFormatter::NONE, 'Europe/Berlin'); $fmt->setPattern('LLL dd'); // Hint: $dto->getTimestamp() is the date a week ago, but with current time. So its always the time its called. $week_start = $fmt->format($dto->getTimestamp()); $dto->modify('+6 days'); // for sunday $week_end = $fmt->format($dto->getTimestamp()); echo $week_start . ' - ' . $week_end;

preferences:
28.98 ms | 486 KiB | 6 Q