用单词中的月份名称更改日期时间

gau*_*lik -1 php

我是Stack Overflow的新手。因此,如果您的问题不清楚,请指导我。

I have a datetime such as 2016-10-08 11:02:55. 
I need to convert it into like this 8 OCT 2016. 
Run Code Online (Sandbox Code Playgroud)

有谁知道我怎么能以这种格式得到它。这必须在PHP中完成。

谢谢。

小智 5

您需要用于strtotime()将目标字符串转换为时间,并用于date()将时间转换为格式化日期。同时strtoupper()转换所有字符为大写。

$x = "2016-10-08 11:02:55";
echo strtoupper(date("j M Y",strtotime($x)));
Run Code Online (Sandbox Code Playgroud)

结果:

8 OCT 2016 
Run Code Online (Sandbox Code Playgroud)

工作演示