views:

58

answers:

1

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

+1  A: 

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';
hsz
This is working but it doesnt insert data into my MySQL table. i cant seem to figure out the solution...thanks
xcodemaddy
Try to print your `$query` and paste into `phpMyAdmin` for example. Check if query has all your data, etc..
hsz
Thanks.$query is showing correct date,but not inserting date into mysql table where as database field datatype is DATETIME.
xcodemaddy