为什么php中的一些DateTime对象需要@符号?


why is a @ symbol required for some DateTime objects in php

创建带有unix时间戳的DateTime对象时,为什么需要在时间戳之前使用'@'符号?

据我所知,这样可以从其他有效格式中识别时间戳。

http://www.php.net/manual/en/datetime.formats.php

unix时间戳在复合格式下

这个问题已经问了很长时间了,但是如果有人还在寻找答案并落在这个问题上。这就是它。

使用"@"符号

echo date("dS M Y ''@'' g:ia");
// 18th Jun 2020 @ 4:20pm

使用'at' text

echo date("dS M Y ''a''t g:ia");
// 18th Jun 2020 at 4:20pm

使用'and' text

echo date("dS M Y ''a''n''d g:ia");
// 18th Jun 2020 and 4:20pm