spikypunker Posted March 13, 2009 Share Posted March 13, 2009 Hi guys, just a really simple problem, i'm bringing in a Date from a Mysql database and it's displaying as yyyy-mm-dd, i'd simply like to reverse this or maybe convert it to just "13th March" etc. Can anyone help out please! Quote Link to comment https://forums.phpfreaks.com/topic/149224-solved-date-format/ Share on other sites More sharing options...
Mark Baker Posted March 13, 2009 Share Posted March 13, 2009 What is the datatype of the column on the database? Are you storing it as a string, or a date/time stamp? The way MySQL displays dates isn't necessarily the way they are actually stored Quote Link to comment https://forums.phpfreaks.com/topic/149224-solved-date-format/#findComment-783641 Share on other sites More sharing options...
spikypunker Posted March 13, 2009 Author Share Posted March 13, 2009 hi there, yes the type of the data in the mysql is "date"... Quote Link to comment https://forums.phpfreaks.com/topic/149224-solved-date-format/#findComment-783737 Share on other sites More sharing options...
Mark Baker Posted March 13, 2009 Share Posted March 13, 2009 In that case, look at the DATE_FORMAT() function in MySQL for your select statement Quote Link to comment https://forums.phpfreaks.com/topic/149224-solved-date-format/#findComment-783751 Share on other sites More sharing options...
spikypunker Posted March 13, 2009 Author Share Posted March 13, 2009 Thanks for the link, i did come across a method like that before, however i've got more details being drawn in from the DB at the same time and would like to know if theres a way of formatting it after selected from the db? Quote Link to comment https://forums.phpfreaks.com/topic/149224-solved-date-format/#findComment-783787 Share on other sites More sharing options...
timmah1 Posted March 13, 2009 Share Posted March 13, 2009 This would be a little easier if you showed us your column name <?php $show = date("F j, Y", strtotime($row['your_field'[)); ?> That will show the month name, like March, then the day without leading zeros, and the year. So in essense March 13, 2009 You could view all of this from here http://us.php.net/date Quote Link to comment https://forums.phpfreaks.com/topic/149224-solved-date-format/#findComment-783792 Share on other sites More sharing options...
spikypunker Posted March 13, 2009 Author Share Posted March 13, 2009 Lol it's coming in as Jan 1 1970, that classic old date! This is the code i used ??? $date = date("F j, Y", strtotime($row['date'])); Quote Link to comment https://forums.phpfreaks.com/topic/149224-solved-date-format/#findComment-783851 Share on other sites More sharing options...
spikypunker Posted March 17, 2009 Author Share Posted March 17, 2009 This is how i managed to solve my problem, just incase anyone needs a simple answer to this... print date("d.m.Y",strtotime("$date")); Done and done Quote Link to comment https://forums.phpfreaks.com/topic/149224-solved-date-format/#findComment-786614 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.