3v4l.org

run code in 300+ PHP versions simultaneously
<?php $m = 1; $y = 2016; echo "Original date Resulting date\n\n"; foreach (range(1, 31) as $day) { if($day <= 9){ $day = '0'.$day; } // this is the important bit $snap = strtotime("monday this week",strtotime("$m/$day/$y")); echo str_pad(date('l',strtotime("$m/$day/$y")), 9, " ", STR_PAD_LEFT)," $m/$day/$y: ",date('r',$snap),"\n"; }

preferences:
68.09 ms | 402 KiB | 5 Q