Reputation:
I am storing the time a player joins my server using a datetime datatype and inserting a CURRENT_TIMESTAMP. All this done in MySQL.
This will look something like this: 2014-04-14 02:15:03
However, on my website I want to display the time they join but on a more friendly way such as:
April 14, 2014 2:15CST
In a nutshell, how do I change "2014-04-14 02:15:03" into "April 14, 2014 2:15CST"?
Thanks!
Upvotes: 0
Views: 62
Reputation: 54
Try to use it like the following:
date('F d, Y H:i', strtotime($mysqlTimestamp));
For more details, check the PHP date function at: http://php.net/manual/en/function.date.php
Upvotes: 0
Reputation: 4866
You can do this:
SELECT DATE_FORMAT(NOW(),'%M %d %Y %h:%i %p') or SELECT DATE_FORMAT(CURRENT_DATE,'%M %d %Y %h:%i %p')
Upvotes: 0
Reputation: 2016
With your mysql timestamp in var $datetime:
$formatted = date("F d, Y H:ie", $datetime);
Refer to date in the PHP manual :)
Upvotes: 1