What is the correct format to pass to the date() function in PHP if I want to insert the result into a MySQL datetime type column?
I've been trying date("Y-M-D G:i:s") but that just inserts "0000-00-00 00:00:00" everytime.
What is the correct format to pass to the date() function in PHP if I want to insert the result into a MySQL datetime type column?
I've been trying date("Y-M-D G:i:s") but that just inserts "0000-00-00 00:00:00" everytime.
You have two options on formatting a datetime ready for mysql:
$date = '04 nov 2016 15:59:25';
$one = new DateTime( $date );
echo $one->format( 'Y-m-d H:i:s' );
$two = date( 'Y-m-d H:i:s', strtotime( $date ) );
echo $two;
Providing that the format in the end is 'Y-m-d H:i:s' then you should be good with mysql datetime columns