3v4l.org

run code in 500+ PHP versions simultaneously
<?php $dt = new DateTime('last week monday 00:00:01', new DateTimeZone('Europe/Berlin')); $year = (int)$dt->format('Y'); $week = (int)$dt->format('W'); // After this, I call a second script with parameters ($year and $week) few times for different tasks $dto = new DateTime(); $dto->setISODate($year, $week); $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/O4dK7:11 Stack trace: #0 {main} thrown in /in/O4dK7 on line 11
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
Mär 18 - Mär 24

preferences:
35.37 ms | 1511 KiB | 10 Q