- 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
<?php
$dateWithHtmlEntities = 'Dec 27 2017, 22:46:15 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');