Format date in MySQL SELECT as ISO 8601

前端 未结 7 2111
攒了一身酷
攒了一身酷 2020-12-05 17:14

I\'m trying to grab the date from my database in a standard timestamp and display it as ISO 8601. I\'m unable to easily do it in PHP so I\'m trying to do it in my SELECT st

7条回答
  •  南方客
    南方客 (楼主)
    2020-12-05 17:22

    You should move the DATE_FORMAT to the select part of your query like this:

    SELECT *, DATE_FORMAT(date,"%Y-%m-%dT%TZ") AS date FROM table_name ORDER BY id DESC
    

提交回复
热议问题