Cine Posted October 24, 2011 Share Posted October 24, 2011 Hi there, I have a string '12/04/1990', that's in the format dd/mm/yyyy. I'm attempting to convert that string to a Date, and then insert that date into a MySQL DATE field. The problem is, every time I try to do so, I keep getting values like this in the database: 1970-01-01. Any ideas? Much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/249715-custom-date-format-to-mysql-date/ Share on other sites More sharing options...
cunoodle2 Posted October 24, 2011 Share Posted October 24, 2011 Show us some code and I'll take a look for you. Quote Link to comment https://forums.phpfreaks.com/topic/249715-custom-date-format-to-mysql-date/#findComment-1281776 Share on other sites More sharing options...
Cine Posted October 24, 2011 Author Share Posted October 24, 2011 Show us some code and I'll take a look for you. I currently have this: Date("Y-m-d", $this->dob); ...which outputs 1970-01-01 and is stored in the database. I need a way of formatting that custom date string ($this->dob) into a format that MySQL can understand which is(Y-m-d). But I don't know how Quote Link to comment https://forums.phpfreaks.com/topic/249715-custom-date-format-to-mysql-date/#findComment-1281780 Share on other sites More sharing options...
Pikachu2000 Posted October 24, 2011 Share Posted October 24, 2011 You should be able to easily use MySQL's STR_TO_DATE() function to accomplish this. Quote Link to comment https://forums.phpfreaks.com/topic/249715-custom-date-format-to-mysql-date/#findComment-1281891 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.