Use timestamp as normal time
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 suc开发者_StackOverflowh?
using date() with strtotime() it is good place to start...
echo date ( 'F j G:i', strtotime ( $row [ 'timestamp' ] ) );
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 ....
精彩评论