joecooper Posted April 20, 2012 Share Posted April 20, 2012 the TIMESTAMP from mysql returns in this format: 2012-04-20 14:25:50 How could I rearrange this with PHP to read as: 04/20/2012 14:25 Thanks Quote Link to comment https://forums.phpfreaks.com/topic/261327-reformat-datetime/ Share on other sites More sharing options...
marcus Posted April 20, 2012 Share Posted April 20, 2012 $cur = "2012-04-20 14:25:50"; echo date("m/d/Y H:i", strtotime($cur)); Quote Link to comment https://forums.phpfreaks.com/topic/261327-reformat-datetime/#findComment-1339157 Share on other sites More sharing options...
PFMaBiSmAd Posted April 20, 2012 Share Posted April 20, 2012 Or you can do this directly in your query when you select the field value (which will be about 8 times faster than using php code) - http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format Quote Link to comment https://forums.phpfreaks.com/topic/261327-reformat-datetime/#findComment-1339158 Share on other sites More sharing options...
joecooper Posted April 20, 2012 Author Share Posted April 20, 2012 Ah, thanks! I always seem to get it wrong. Thats nice and simple! Thanks Quote Link to comment https://forums.phpfreaks.com/topic/261327-reformat-datetime/#findComment-1339159 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.