Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL -PHP insert DATETIME

can anyone please guide me on How to insert a DATETIME filed from iphone through PHP script into MySQL database.

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

$query = "INSERT INTO timeTable(time) VALUES ('$dates')";

Thank you..

like image 743
xcodemaddy Avatar asked Dec 28 '22 09:12

xcodemaddy


1 Answers

For date() function as a second argument you should pass a timestamp.

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

But you have already your time in a good form sou you should just do:

$dates = '2010-10-12 15:09:00';
like image 148
hsz Avatar answered Dec 31 '22 11:12

hsz