Hello I'd doing a project which is related to android , php and mysql, there is this function that i need to get the user input from android device, and post it to php script which then query the database, one of the inputs is a time string the format is "XX:XX:XX" , this string will be stored as a time in mysql, my question is how do I convert the string into mysql time format in php ? (only time, NO DATE)
3 Answers
according to http://dev.mysql.com/doc/refman/5.0/en/time.html, the TIME type should accept strings formatted like 'HH:MM:SS' so you should be able to directly save your data without the need to convert anything.
Comments
To convert the date in a mysql Timestamp format you can use the following snippet :
$mysqlTime = date("H:i:s", strtotime("20:30:10"));
the variable $mysqlTime will hold it for you.
I think I clearly understood your question.
3 Comments
Suresh Kamrushi
He mention that "only time, NO DATE" and you are giving him date also.
user1452954
Thank you ! But it didn't work, when I do the insert, and checked myphpadmin it shows 00:00:00, and I already post that I do not want date at the beginning I'm storing time only
Mihai Enescu
Please paste me the column format that your mysql DB Uses . It's DATE , DATETIME or TIMESTAMP ?