MySQL stores dates in the format YYYY-MM-DD… which is great, it’s consistent and easy to understand—If you happen to be a computer. Unfortunately, this format is rather confusing for humans, especially for humans which may be trying to communicate with individuals who read dates differently. For example, those of us in the US usually record the 10th of May in the year 2016 as 05/10/2016 whereas individuals in other countries often record the same date as 10/05/2016, causing considerable confusion in communication.
So what do we do to solve this? When in doubt, write it out! Here’s how to take a date retrieved from a MySQL database by PHP and convert it to an international human-friendly format.
We’ll first assume that you have retrieved your data into array
$myrow. Say the date stored in MySQL is
2016-01-04. Here’s how to display it in various forms. Precede each of these by
|January 04, 2016||
|Monday, January 04, 2016||
|Jan 04, 2016||
|04 January 2016||
|04 Jan 2016||
|Mon, 04 Jan 2016||
|Monday, the 4th of January, 2016||
Search Help: Visitors seeking this information might use the following search strings: “How do I display MySQL dates in other formats?”, “MySQL dates PHP”, “MySQL datestamp field”, “MySQL datestamp format”, “MySQL PHP date format”, “”MySQL PHP date conversion”, “Convert MySQL date in PHP”.