webref.eu Posted June 5, 2009 Share Posted June 5, 2009 Hi All I'm lifting a date and time field from my database and displaying it on the page with: echo "Date Added: " . $row[ProductDateAdded] . "<br /><br />"; which gives me date and time results like: 2009-06-02 11:38:35 However, I just want the date formatted to an American standard as follows: Jun 2 2009 So what's the code to do that please? Many thanks Quote Link to comment https://forums.phpfreaks.com/topic/161067-solved-easy-date-formatting-question/ Share on other sites More sharing options...
PFMaBiSmAd Posted June 5, 2009 Share Posted June 5, 2009 http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_date-format Quote Link to comment https://forums.phpfreaks.com/topic/161067-solved-easy-date-formatting-question/#findComment-849985 Share on other sites More sharing options...
webref.eu Posted June 5, 2009 Author Share Posted June 5, 2009 OK, thanks, the code I needed was: echo "Date Added: " . date('M d Y', strtotime($row[ProductDateAdded])) . "<br /><br />"; Rgds Quote Link to comment https://forums.phpfreaks.com/topic/161067-solved-easy-date-formatting-question/#findComment-849988 Share on other sites More sharing options...
PFMaBiSmAd Posted June 5, 2009 Share Posted June 5, 2009 Changing the format in the SELECT query is 8-10 times faster than using php code, in case you have a lot of data or your site has a lot of visitors. (Edit: actually the time it adds to the query, that you are executing anyway, makes it several hundred times faster than using php code.) Quote Link to comment https://forums.phpfreaks.com/topic/161067-solved-easy-date-formatting-question/#findComment-849992 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.