4

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
  • FYI Im sending the date from Iphone form to the php script. Commented Aug 4, 2010 at 6:50

1 Answer 1

10

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';
Sign up to request clarification or add additional context in comments.

3 Comments

This is working but it doesnt insert data into my MySQL table. i cant seem to figure out the solution...thanks
Try to print your $query and paste into phpMyAdmin for example. Check if query has all your data, etc..
Thanks.$query is showing correct date,but not inserting date into mysql table where as database field datatype is DATETIME.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.