xionhack Posted January 25, 2009 Share Posted January 25, 2009 Hello, I have a query, and when I run it the date is never inserted. What is the problem? The field where that date is inserted is a "date" type. Can somebody tell me what is the problem? Thanks! INSERT INTO activity (type_activity, details, date, member_id) VALUES (1, 'activity', '1/1/2009', 1) Link to comment https://forums.phpfreaks.com/topic/142365-problem-inserting-date/ Share on other sites More sharing options...
Mchl Posted January 25, 2009 Share Posted January 25, 2009 Date must be inserted in YYYYMMDD, YYYY-MM-DD, YYYY/MM/DD etc formats Link to comment https://forums.phpfreaks.com/topic/142365-problem-inserting-date/#findComment-745927 Share on other sites More sharing options...
xionhack Posted January 25, 2009 Author Share Posted January 25, 2009 Thanks for your quick response. Is there a way for it to insert it independently of how you write it? Something like a conversion function or something like that Link to comment https://forums.phpfreaks.com/topic/142365-problem-inserting-date/#findComment-745928 Share on other sites More sharing options...
Mchl Posted January 25, 2009 Share Posted January 25, 2009 On MySQL side STR_TO_DATE() On PHP side date and strtotime Link to comment https://forums.phpfreaks.com/topic/142365-problem-inserting-date/#findComment-745929 Share on other sites More sharing options...
xionhack Posted January 25, 2009 Author Share Posted January 25, 2009 Thanks! How will it know which one is the month and which one is the day? Link to comment https://forums.phpfreaks.com/topic/142365-problem-inserting-date/#findComment-745930 Share on other sites More sharing options...
Mchl Posted January 25, 2009 Share Posted January 25, 2009 You have to tell it to STR_TO_DATE strtotime() recognizes only some formats Link to comment https://forums.phpfreaks.com/topic/142365-problem-inserting-date/#findComment-745931 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.