I have a time string which is formated (nearly) with this format M j Y H:iA
. The Problem is, that the month is localized in german. So instead of "Dec 31 2014 12:00AM" there is "Dez 31 2014 12:00AM".
This is what I tried already but did not work. $date
is false
;
$input = 'Dez 31 2014 12:00AM';
$format = 'M j Y H:iA';
$oldLocale = setlocale(LC_TIME, 0);
setlocale(LC_TIME, 'de_DE@euro', 'de_DE', 'de_DE.utf8', 'deu_deu');
$date = DateTime::createFromFormat($format, $input);
setlocale(LC_TIME, $oldLocale);
$out = $date->format("Y-m-d H:i:s");
Is there a way to parse that string without manual string parsing?