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;
Output for 8.5.1 - 8.5.11
Fatal error: Uncaught Error: Class "IntlDateFormatter" not found in /in/de5CL:8 Stack trace: #0 {main} thrown in /in/de5CL on line 8
Process exited with code 255.
Output for 8.1.0 - 8.1.34, 8.2.0 - 8.2.35, 8.3.0 - 8.3.36, 8.4.1 - 8.4.27, 8.5.0
Jan 02 - Jan 08

preferences:
33.26 ms | 1511 KiB | 10 Q