3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @param String $dateString * @return DateTime */ function updateDate($dateString){ $suppliedDate = new \DateTime($dateString); $currentYear = (int)(new \DateTime())->format('Y'); return (new \DateTime())->setDate($currentYear, (int)$suppliedDate->format('m'), (int)$suppliedDate->format('d')); } var_dump(updateDate('8th August 2011'));

preferences:
49.34 ms | 404 KiB | 5 Q