3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $m = 1; $y = 2016; 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 'Snapping ',str_pad(date('l',strtotime("$m/$day/$y")), 9, " ", STR_PAD_LEFT)," $m/$day/$y results: ",date('r',$snap),"\n"; }
based on 34YOl
Output for 5.6.23 - 5.6.28, 7.0.8 - 7.2.0
Snapping Friday 1/01/2016 results: Mon, 28 Dec 2015 00:00:00 +0100 Snapping Saturday 1/02/2016 results: Mon, 28 Dec 2015 00:00:00 +0100 Snapping Sunday 1/03/2016 results: Mon, 28 Dec 2015 00:00:00 +0100 Snapping Monday 1/04/2016 results: Mon, 04 Jan 2016 00:00:00 +0100 Snapping Tuesday 1/05/2016 results: Mon, 04 Jan 2016 00:00:00 +0100 Snapping Wednesday 1/06/2016 results: Mon, 04 Jan 2016 00:00:00 +0100 Snapping Thursday 1/07/2016 results: Mon, 04 Jan 2016 00:00:00 +0100 Snapping Friday 1/08/2016 results: Mon, 04 Jan 2016 00:00:00 +0100 Snapping Saturday 1/09/2016 results: Mon, 04 Jan 2016 00:00:00 +0100 Snapping Sunday 1/10/2016 results: Mon, 04 Jan 2016 00:00:00 +0100 Snapping Monday 1/11/2016 results: Mon, 11 Jan 2016 00:00:00 +0100 Snapping Tuesday 1/12/2016 results: Mon, 11 Jan 2016 00:00:00 +0100 Snapping Wednesday 1/13/2016 results: Mon, 11 Jan 2016 00:00:00 +0100 Snapping Thursday 1/14/2016 results: Mon, 11 Jan 2016 00:00:00 +0100 Snapping Friday 1/15/2016 results: Mon, 11 Jan 2016 00:00:00 +0100 Snapping Saturday 1/16/2016 results: Mon, 11 Jan 2016 00:00:00 +0100 Snapping Sunday 1/17/2016 results: Mon, 11 Jan 2016 00:00:00 +0100 Snapping Monday 1/18/2016 results: Mon, 18 Jan 2016 00:00:00 +0100 Snapping Tuesday 1/19/2016 results: Mon, 18 Jan 2016 00:00:00 +0100 Snapping Wednesday 1/20/2016 results: Mon, 18 Jan 2016 00:00:00 +0100 Snapping Thursday 1/21/2016 results: Mon, 18 Jan 2016 00:00:00 +0100 Snapping Friday 1/22/2016 results: Mon, 18 Jan 2016 00:00:00 +0100 Snapping Saturday 1/23/2016 results: Mon, 18 Jan 2016 00:00:00 +0100 Snapping Sunday 1/24/2016 results: Mon, 18 Jan 2016 00:00:00 +0100 Snapping Monday 1/25/2016 results: Mon, 25 Jan 2016 00:00:00 +0100 Snapping Tuesday 1/26/2016 results: Mon, 25 Jan 2016 00:00:00 +0100 Snapping Wednesday 1/27/2016 results: Mon, 25 Jan 2016 00:00:00 +0100 Snapping Thursday 1/28/2016 results: Mon, 25 Jan 2016 00:00:00 +0100 Snapping Friday 1/29/2016 results: Mon, 25 Jan 2016 00:00:00 +0100 Snapping Saturday 1/30/2016 results: Mon, 25 Jan 2016 00:00:00 +0100 Snapping Sunday 1/31/2016 results: Mon, 25 Jan 2016 00:00:00 +0100
Output for 5.5.0 - 5.6.22, 7.0.0 - 7.0.7
Snapping Friday 1/01/2016 results: Mon, 28 Dec 2015 00:00:00 +0100 Snapping Saturday 1/02/2016 results: Mon, 28 Dec 2015 00:00:00 +0100 Snapping Sunday 1/03/2016 results: Mon, 04 Jan 2016 00:00:00 +0100 Snapping Monday 1/04/2016 results: Mon, 04 Jan 2016 00:00:00 +0100 Snapping Tuesday 1/05/2016 results: Mon, 04 Jan 2016 00:00:00 +0100 Snapping Wednesday 1/06/2016 results: Mon, 04 Jan 2016 00:00:00 +0100 Snapping Thursday 1/07/2016 results: Mon, 04 Jan 2016 00:00:00 +0100 Snapping Friday 1/08/2016 results: Mon, 04 Jan 2016 00:00:00 +0100 Snapping Saturday 1/09/2016 results: Mon, 04 Jan 2016 00:00:00 +0100 Snapping Sunday 1/10/2016 results: Mon, 11 Jan 2016 00:00:00 +0100 Snapping Monday 1/11/2016 results: Mon, 11 Jan 2016 00:00:00 +0100 Snapping Tuesday 1/12/2016 results: Mon, 11 Jan 2016 00:00:00 +0100 Snapping Wednesday 1/13/2016 results: Mon, 11 Jan 2016 00:00:00 +0100 Snapping Thursday 1/14/2016 results: Mon, 11 Jan 2016 00:00:00 +0100 Snapping Friday 1/15/2016 results: Mon, 11 Jan 2016 00:00:00 +0100 Snapping Saturday 1/16/2016 results: Mon, 11 Jan 2016 00:00:00 +0100 Snapping Sunday 1/17/2016 results: Mon, 18 Jan 2016 00:00:00 +0100 Snapping Monday 1/18/2016 results: Mon, 18 Jan 2016 00:00:00 +0100 Snapping Tuesday 1/19/2016 results: Mon, 18 Jan 2016 00:00:00 +0100 Snapping Wednesday 1/20/2016 results: Mon, 18 Jan 2016 00:00:00 +0100 Snapping Thursday 1/21/2016 results: Mon, 18 Jan 2016 00:00:00 +0100 Snapping Friday 1/22/2016 results: Mon, 18 Jan 2016 00:00:00 +0100 Snapping Saturday 1/23/2016 results: Mon, 18 Jan 2016 00:00:00 +0100 Snapping Sunday 1/24/2016 results: Mon, 25 Jan 2016 00:00:00 +0100 Snapping Monday 1/25/2016 results: Mon, 25 Jan 2016 00:00:00 +0100 Snapping Tuesday 1/26/2016 results: Mon, 25 Jan 2016 00:00:00 +0100 Snapping Wednesday 1/27/2016 results: Mon, 25 Jan 2016 00:00:00 +0100 Snapping Thursday 1/28/2016 results: Mon, 25 Jan 2016 00:00:00 +0100 Snapping Friday 1/29/2016 results: Mon, 25 Jan 2016 00:00:00 +0100 Snapping Saturday 1/30/2016 results: Mon, 25 Jan 2016 00:00:00 +0100 Snapping Sunday 1/31/2016 results: Mon, 01 Feb 2016 00:00:00 +0100