How to Alter Date Format to dd/mm/yyyy in PHP MySQL
When retrieving dates from a MySQL database, you may encounter the default 'YYYY-MM-DD' format. If you prefer the dd/mm/yyyy format, there are several approaches to achieve this transformation.
PHP 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 Solution:
SELECT date_format(curdate(), '%d/%m/%Y');
The above is the detailed content of How to Change MySQL and PHP Date Formats to dd/mm/yyyy?. For more information, please follow other related articles on the PHP Chinese website!