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" Link to comment https://forums.phpfreaks.com/topic/170437-solved-date-formating-help/ Share on other sites More sharing options...
Jessica Posted August 15, 2009 Share Posted August 15, 2009 try using the functions strtotime() and date() Link to comment https://forums.phpfreaks.com/topic/170437-solved-date-formating-help/#findComment-899047 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 Link to comment https://forums.phpfreaks.com/topic/170437-solved-date-formating-help/#findComment-899053 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. Link to comment https://forums.phpfreaks.com/topic/170437-solved-date-formating-help/#findComment-899084 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. Link to comment https://forums.phpfreaks.com/topic/170437-solved-date-formating-help/#findComment-899964 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.