busnut Posted February 1, 2009 Share Posted February 1, 2009 G'day I've tried finding the answer on google, but it seems to be giving me the end user result, what i'm looking for is in myphpadmin panel, I want to change the preset date format of 0000-00-00 (which appears to represent year/month/day) to be 00-00-0000 (day/month/year or d/m/Y), but everwhere i've read it shows code you put into the php file. So currently my 1900 odd records are all in d/m/Y format, and trying to insert all of them into the database is not working as it keeps going back to its date format default. I've selected 'Date' as the type for this field, so not sure if thats the right thing to do first, if not, what is, and if it is, how do I change the format? Cheers Quote Link to comment https://forums.phpfreaks.com/topic/143373-change-date-format/ Share on other sites More sharing options...
Mchl Posted February 1, 2009 Share Posted February 1, 2009 You can't change the date format in MySQL. It's fixed, and for a good reason. You can however change the way it is displayed. Most of the time it is done in PHP that's why you get so many hits for that. There are however MySQL date formatting functions. http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html Quote Link to comment https://forums.phpfreaks.com/topic/143373-change-date-format/#findComment-751979 Share on other sites More sharing options...
busnut Posted February 1, 2009 Author Share Posted February 1, 2009 Ok, so if i've understood this correctly, if i left it as the formated 0000-00-00 (Y-m-d) format, I then change my php pages to show the date in the format I prefer then? Quote Link to comment https://forums.phpfreaks.com/topic/143373-change-date-format/#findComment-751982 Share on other sites More sharing options...
Mchl Posted February 1, 2009 Share Posted February 1, 2009 Yup. And when storing dates, you use either PHP's date or mysql's STR_TO_DATE() to convert dates input in whatever format to MySQL compatible format. Quote Link to comment https://forums.phpfreaks.com/topic/143373-change-date-format/#findComment-751987 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.