3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function last_monday($date) { if (!is_numeric($date)) $date = strtotime($date); if (date('w', $date) == 1) return $date; else return strtotime( 'last monday', $date ); } echo date('m/d/y', last_monday('8/14/2012')); // 8/13/2012 (tuesday gives us the previous monday) echo date('m/d/y', last_monday('8/13/2012')); // 8/13/2012 (monday throws back that day) echo date('m/d/y', last_monday('8/12/2012')); // 8/06/2012 (sunday goes to previous week)
Output for 4.3.0 - 5.0.5, 5.1.1 - 5.6.23, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
08/13/1208/13/1208/06/12
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/llKWe on line 16
Process exited with code 255.