php convert european datetime to mysql datetime
- by Mathlight
I'm really stuck with this problem. I've got an datetime string like this: 28-06-14 11:01:00
I'm trying to convert it to 2014-06-28 11:01:00 so that i can insert it into the database ( with field type datetime.
I've tryed multiple things like this:
$datumHolder = new DateTime($data['datum'], new DateTimeZone('Europe/Amsterdam'));
$datum1 = $datumHolder -> format("Y-m-d H:i:s");
$datum2 = date( 'Y-m-d', strtotime(str_replace('-', '/', $data['datum']) ) );
$datum3 = DateTime::createFromFormat( 'Y-m-d-:Hi:s', $data['datum']);
This is the output i get:
datum1: 2028-06-14 11:01:00
datum2: 1970-01-01
And i get an error for datum3:
echo "datum3: " . $datum3->format( 'Y-m-d H:i:s'); . '<br />';
Call to a member function format() on a non-object
So my question is very clear... What am I doing wrong / how to get this working?
Thanks in advantage guys!
I know that this question is asked many, many times... But whatever i try, i can't get it working...