3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $givenday = mktime(0,0,0,01,01,2013); $Monday = strtotime("Monday this week",$givenday); echo date("j M Y H:i:s", $Monday); function StartOfWeek($year, $week) { $Jan1 = mktime(1,1,1,1,1,$year); $MondayOffset = (11-date('w',$Jan1))%7-3; $desiredMonday = strtotime(($week-1) . ' weeks '.$MondayOffset.' days', $Jan1); return $desiredMonday; } echo StartOfWeek(2013, 1);
Output for 5.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
31 Dec 2012 00:00:001356912061
Output for 4.3.5 - 4.4.9, 5.0.3 - 5.2.17
7 Jan 2013 00:00:001356912061
Output for 5.0.0 - 5.0.2
7 Jan 2013 00:00:001356908400
Output for 4.3.0 - 4.3.4
14 Jan 2013 00:00:001356912061