Reputation: 10111
I'd like to "transform" the CURRENT_TIMESTAMP from the MySQL field type timestamp into a more readable format, such as:
2011-03-20 14:05:34
to
March 20 at 2:05 PM
But I'd also like to use a variable to make the time be in 24h format,
March 20 at 14:05
What PHP code could I use to do such?
Upvotes: 0
Views: 474
Reputation: 56357
Date_format is your friend :)
http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format
select date_format('2011-03-20 14:05:34','%M %d at %H:%i') as my_date ....
Upvotes: 1
Reputation: 25564
using date() with strtotime() it is good place to start...
echo date ( 'F j G:i', strtotime ( $row [ 'timestamp' ] ) );
Upvotes: 4