bajangerry Posted August 15, 2009 Share Posted August 15, 2009 Hi Guys, I am back for more! I want to import data from a CSV file that includes a date field formated dd/mm/yyyy and I am having a problem with the MySQL table as its date field is formated yyyy-mm-dd. How can I use PHP to convert this date to match the MySQL requirements during the import from CSV? Or can I somehow convert the table to match the CSV format? CSV example data is: "15/05/2009","2345234","07:45" Quote Link to comment Share on other sites More sharing options...
Jessica Posted August 15, 2009 Share Posted August 15, 2009 try using the functions strtotime() and date() Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted August 15, 2009 Share Posted August 15, 2009 Using the mysql STR_TO_DATE function directly in an INSERT query would result in the greatest performance - http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_str-to-date Quote Link to comment Share on other sites More sharing options...
bajangerry Posted August 15, 2009 Author Share Posted August 15, 2009 PFMaBiSmAd can you give me a simple code example on how I would use this based on the CSV exmaple I gave above? I am not sure I am following how I would use the function in a single INSERT query. Quote Link to comment Share on other sites More sharing options...
bajangerry Posted August 17, 2009 Author Share Posted August 17, 2009 Never mind guys, I got around the problem. 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.