c_pattle Posted September 13, 2010 Share Posted September 13, 2010 I was just wondering if anyone can reccomend the best way to get dates from a database and turn them into dates you can display. For example if you have a date stored such as 23/08/10, is there an easy way to turn this into 23rd August 2010? Thanks for any help. Quote Link to comment https://forums.phpfreaks.com/topic/213316-phpmysql-dates/ Share on other sites More sharing options...
The Little Guy Posted September 13, 2010 Share Posted September 13, 2010 first off I would store the date as a DATE field, which would be formatted like so: YYYY-MM-DD next, after you call it, you would use the date funciton: echo date('dS F Y', strtotime($row['date'])); Quote Link to comment https://forums.phpfreaks.com/topic/213316-phpmysql-dates/#findComment-1110695 Share on other sites More sharing options...
c_pattle Posted September 13, 2010 Author Share Posted September 13, 2010 Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/213316-phpmysql-dates/#findComment-1110700 Share on other sites More sharing options...
schilly Posted September 13, 2010 Share Posted September 13, 2010 Or do it directly in your query: SELECT DATE_FORMAT(date_field, '%b %d %Y') as date from table Quote Link to comment https://forums.phpfreaks.com/topic/213316-phpmysql-dates/#findComment-1110723 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.