yoda699 Posted November 24, 2009 Share Posted November 24, 2009 Hey, So I got a form that requires the user to insert: the hour, the minuets, and if its AM or PM. what I get is three variables: $hour $minuets $amPm Those variables are combined into a string. I need to convert this somehow to readable format for mysql server and insert the data. I found loads of function to convert date from mysql into strings, but not the other way around. Any suggestions about this issue? Thanks, Link to comment https://forums.phpfreaks.com/topic/182781-format-a-string-into-mysql-datetime/ Share on other sites More sharing options...
dgoosens Posted November 24, 2009 Share Posted November 24, 2009 in MySQL make the data DATETIME in PHP $date = date("Y-m-d H:i:s"); (for instance) http://uk.php.net/manual/en/function.date.php Link to comment https://forums.phpfreaks.com/topic/182781-format-a-string-into-mysql-datetime/#findComment-964721 Share on other sites More sharing options...
Mchl Posted November 24, 2009 Share Posted November 24, 2009 http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_str-to-date Link to comment https://forums.phpfreaks.com/topic/182781-format-a-string-into-mysql-datetime/#findComment-964730 Share on other sites More sharing options...
yoda699 Posted November 24, 2009 Author Share Posted November 24, 2009 STR_TO_DATE is an mysql function. is there a php equivalent? Link to comment https://forums.phpfreaks.com/topic/182781-format-a-string-into-mysql-datetime/#findComment-964737 Share on other sites More sharing options...
thebadbad Posted November 24, 2009 Share Posted November 24, 2009 Something like echo date('H:i:s', strtotime('03:50 PM')); ? Link to comment https://forums.phpfreaks.com/topic/182781-format-a-string-into-mysql-datetime/#findComment-964744 Share on other sites More sharing options...
Mchl Posted November 24, 2009 Share Posted November 24, 2009 Since you want to put in MySQL, I thought MySQL function will work for you thebadbad's solution should work Link to comment https://forums.phpfreaks.com/topic/182781-format-a-string-into-mysql-datetime/#findComment-964746 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.