3v4l.org

run code in 300+ PHP versions simultaneously
<?php $year = date_create('today')->format('Y'); //remove comment next line for test's //$year = 2001; $dtStart = date_create('2 jan '.$year)->modify('last Monday'); $dtEnd = date_create('last monday of Dec '.$year); for($weeks = [];$dtStart <= $dtEnd;$dtStart->modify('+1 week')){ $key = $dtStart->format('W-Y'); $from = $dtStart->format('d/m/Y'); $to = (clone $dtStart)->modify('+6 Days')->format('d/m/Y'); $weeks[$key] = $from.' - '.$to; } var_export($weeks);

Abusive script

This script was stopped while abusing our resources


preferences:
29.49 ms | 405 KiB | 5 Q