Home >Backend Development >PHP Tutorial >How to Efficiently Convert yyyy-mm-dd to dd-mm-yyyy in PHP?
When faced with the task of converting a date from the yyyy-mm-dd format to dd-mm-yyyy using PHP, it can be challenging to understand how to handle the timestamp requirement. This article provides a comprehensive explanation and a simple solution to address this issue.
Question: How to convert a date from yyyy-mm-dd to dd-mm-yyyy without using SQL?
Answer:
To convert the date format, follow these steps:
For example, to convert the date "2010-03-21" to the "dd-mm-yyyy" format:
$originalDate = "2010-03-21"; $newDate = date("d-m-Y", strtotime($originalDate)); echo $newDate; // Output: 21-03-2010
Additional Notes:
Here are some useful resources for further exploration:
The above is the detailed content of How to Efficiently Convert yyyy-mm-dd to dd-mm-yyyy in PHP?. For more information, please follow other related articles on the PHP Chinese website!