MySQL Insert -PHP DATETIME

can anyone direct me to a question on how to insert the DATETIME filed from iphone via a PHP script into a MySQL database.

$dates = date('Ymd H:i:s','2010-10-12 15:09:00'); $query = "INSERT INTO timeTable(time) VALUES ('$dates')"; 

Thanks..

+4
source share
1 answer

For the date() function, you must pass a timestamp as the second argument.

 $dates =date('Ymd H:i:s', strtotime('2010-10-12 15:09:00') ); 

But you already have time in good shape, and you should just do:

 $dates = '2010-10-12 15:09:00'; 
+10
source

All Articles