I'm storing a datetime timestamp in the database (SQL Server).
I simply use this to get the current time: date('Y-m-d H:i:s')
which works fine.
In the database it looks exactly the same (the format), however, when I get the datetime from the database the format is completely off.
The date is for example displayed in the database as 19-4-2016 13:29:36, but when I read the data in PHP it becomes apr 19 2016 01:29:36:000.
My code for reading it from the database:
$dateFromDB = /* Sql query here.. */;
$myTimestamp = date('Y-m-d H:i:s', strtotime($dateFromDB));
The $dateFromDB variable echos: apr 19 2016 01:29:36:000
The $myTimestampechos: 1970-01-01 01:00:00
The date is stored in the database as datetime, be aware that the date format looks good inside the database table, it's messed up when it is being read at the PHP side.

DATETIMEor is it actually aVARCHAR? Regardless, you can useDateTime::createFromFormat(). Also, are you running MySQL or MsSQL? You've tagged it with MySQL but "Microsoft SQL Server" is not MySQL.strtotimeanddatefunction. Simpleecho $dateFromDB. I don't think you need to convert value