xcodemaddy
xcodemaddy

Reputation: 71

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..

Upvotes: 4

Views: 17926

Answers (1)

hsz
hsz

Reputation: 152304

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';

Upvotes: 10

Related Questions