3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $dt = "22-09-2017"; function getDay($day,$date) { $days = ['Monday' => 1, 'Tuesday' => 2, 'Wednesday' => 3, 'Thursday' => 4, 'Friday' => 5, 'Saturday' => 6, 'Sunday' => 7]; $date = new \DateTime($date); $date->setISODate((int)$date->format('o'), (int)$date->format('W'), $days[ucfirst($day)]); return $date; } echo getDay('Monday',$dt)->format("d-m-Y");
based on ioINc
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.0 - 7.3.0beta1
18-09-2017