Reputation: 37
I am using a DATE field in my MYSQL table, and pulling it through on a php page. The problem is it comes out as "2011-04-23"
Is there a way I can reformat this as 23/04/2011?
Thanks :)
Upvotes: 0
Views: 769
Reputation: 5609
Assuming variable $date contains your MySQL data:
$date = '2011-04-23';
$timezone = 'Europe/London'; // this is optional argument
$formatted = DateTime::createFromFormat('Y-m-d', $date, new DateTimeZone($timezone));
// or without the optional timezone - where php will assume the default timezone from your OS
$formatted = DateTime::createFromFormat('Y-m-d', $date);
echo $formatted->('d/m/Y');
Upvotes: 0
Reputation: 776
DATE_FORMAT(date,format)
Look here: http://dev.mysql.com/doc/refman/5.0/es/date-and-time-functions.html
Upvotes: 1