3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dateWithHtmlEntities = 'Dec&nbsp;27&nbsp;2017,&nbsp;22:46:15&nbsp;CET'; $dateWithUTF8Chars = html_entity_decode($dateWithHtmlEntities); $dateInPlainASCII = iconv('UTF-8', 'US-ASCII//TRANSLIT//IGNORE', $dateWithUTF8Chars); $dateTimeObject = DateTime::createFromFormat('M d Y, H:i:s T', $dateInPlainASCII); if (!$dateTimeObject) { // TODO handle errors your own way throw new InvalidArgumentException('Date could not be parsed: ' . $decodedDate); } echo 'Final date: ' . $dateTimeObject->format('Y-m-d H:i:s');
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
Final date: 2017-12-27 22:46:15

preferences:
82.35 ms | 406 KiB | 5 Q