Change Date Format to dd/mm/yyyy in PHP MySQL
In MySQL, date is stored in 'YYYY-MM-DD' format by default. This format may not be user-friendly for certain applications. This article presents several methods to transform the date format to dd/mm/yyyy.
PHP-based Solutions:
$timestamp = strtotime($date_from_db); echo date('d/m/Y', $timestamp);
$date = new DateTime('2010-03-19'); echo $date->format('d/m/Y');
MySQL-based Solutions:
SELECT date_format(curdate(), '%d/%m/%Y');
The above is the detailed content of How to Change MySQL Date Format to dd/mm/yyyy in PHP and SQL?. For more information, please follow other related articles on the PHP Chinese website!