Reputation: 2645
How can I change the current date format which is: YY/MM/DD to something like Oct 8th 2013.
This will be pulled straight from database.
Was not sure what to google in-order to find this. Thanks.
Upvotes: 0
Views: 100
Reputation: 1
Sql get current time:
select DATE_FORMAT(NOW(),'%b %D %Y') FROM table;
or date format the exist time:
SELECT DATE_FORMAT(time, '%b %D %Y) FROM table;
Upvotes: 0
Reputation: 4736
As I linked in comments, use DateTime::createFromFormat
And the resulting code would be something like:
$date = "13/10/08";
$tmp = DateTime::createFromFormat("y/m/d", $date);
echo $tmp->format("M jS Y");
Output:
Oct 8th 2013
Upvotes: 1
Reputation: 13283
Use the DateTime
class:
$time = DateTime::createFromFormat('y/m/d', '13/10/13');
if ( ! $time) {
die('Date is invalid!');
}
echo $time->format('M jS Y');
Upvotes: 1