Neither example work as you have multiple errors:
- You forgot your second parameter to
Datetime::createFromFormat()
h:i:s
should beH:i:s
- Your date in the second example is separated by a
.
not a-
Fixes:
<?php
$date = "13-06-2015 23:45:52";
echo DateTime::createFromFormat('d-m-Y H:i:s', $date)->format('Y-m-d h:i:s');
$date = "10.06.2015 09:25:52";
echo DateTime::createFromFormat('d.m.Y H:i:s', $date)->format('Y-m-d h:i:s');
?>