[英]DATE_FORMAT() in MySQL query
I'm trying to change this timestamp 我正在尝试更改此时间戳
2010-08-02 00:28:20
2010-08-02 00:28:20
to month/day/year - 到月/日/年-
08/02/10
10/08/02
..in the query (I know that doing it in the query is faster). ..在查询中(我知道在查询中这样做更快)。
$sql = "SELECT * FROM posts ORDER BY post_date DESC";
I tried using the DATE_FORMAT() in the query many ways but I can't seem to get it right.. Can someone please share how to do this? 我尝试以多种方式在查询中使用DATE_FORMAT(),但似乎无法正确执行。有人可以分享如何做到这一点吗?
使用DATE_FORMAT()上的手册 :
SELECT DATE_FORMAT(post_date, "%m/%d/%y");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.