I'm grabbing a date from an API and trying to insert that date into a table in my database. However, no matter what I try it either fails to insert anything (i.e errors) or it just inserts 0000-00-00 00:00:00.
The fieldtype in the table is DATETIME.
The format the date comes in in the API JSON is like follows:
2016-08-28T15:00:00Z
I've tried converting to all sorts. I've tried the following
$date = 2016-08-28T15:00:00Z;
$date = strtotime($date);
$finalDate = date('Y-m-d h:m:s', $date);
echo $finalDate;
//this echos the date in the format I'd expect to see it in the database - 2016-08-28 15:00:00
But when I insert $finalDate into the table it goes it errors. (Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation:)
Any ideas?