searls03 Posted March 17, 2011 Share Posted March 17, 2011 How can I convert a database time to mm/dd/yyyy from yyyy-mm-dd when pulling from database to display, and vice versa when from form to database? Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted March 17, 2011 Share Posted March 17, 2011 Retrieving: use the MySQL function DATE_FORMAT() Inserting depends on how the date is formatted to begin with, and whether you're validating and enforcing that format. Quote Link to comment Share on other sites More sharing options...
searls03 Posted March 17, 2011 Author Share Posted March 17, 2011 It will always be mm/dd/yyyy for it will be a calendar that pops up to make sure it is that format............ Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted March 17, 2011 Share Posted March 17, 2011 Then using two php functions, date() and strtotime() will work. $date_string = '12/31/2004'; $formatted_date = date( 'Y-m-d', strtotime($date_string) ); Quote Link to comment Share on other sites More sharing options...
searls03 Posted March 17, 2011 Author Share Posted March 17, 2011 Where exactly will I put these in my PHP code? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.