Reputation: 226
I have date stored in MySQL DB using CURRENT_TIMESTAMP
as default, so that when a new data is inserted the date and time is stored automatically. And, I want to retrieve this data and display in my PHP
. The retrived data looks like this 2019-03-17 15:02:36
.
Now I need to change it to March 17 2019
in my output.
I tried using date_format()
but it is not displaying any output. It just returns blank data.
How can I achieve this.
Upvotes: 0
Views: 36
Reputation: 300
Its quite simple use below code
SELECT *, DATE_FORMAT(YOURDATECOLUMN,'%d/%m/%Y') AS niceDate
FROM table
ORDER BY YOURDATECOLUMN DESC
Fiddle : http://sqlfiddle.com/#!9/9eecb/82244
Upvotes: 1