Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在 2013 年 8 月 9 日之前将日期格式更改为 2013 年 8 月 9 日,我试过这个:
echo $date=date("Y-m-d"); //output 2013-08-09 echo date("d-M-Y",mktime(0-0-0,$date));
但是这段代码显示10-Aug-2013 我不知道为什么显示日期 10 而不是 09。
10-Aug-2013
非常感谢您的回答,在此先感谢
以下更容易:
echo date("d-M-Y",strtotime($date));
在 mktime 你必须减去一天
您没有mktime正确传递参数。mktime需要 6 个整数参数,因为这里有 1 个整数和 1 个字符串。
mktime
尝试改用一个DateTime对象:
DateTime
$date = new DateTime(); echo $date->format('d-M-Y');