PHP 在 Date() 中添加单词“at”


PHP add the word 'at' in Date()

 $dateFormatted = date("l, M j g:i a", strtotime($day .' '. $preferTime )      );

很简单,但找不到

我想在我的月份和时间之间说"at",显然"a"和"t"是保留的。我能做什么?

我应该这样做吗? 必须有更聪明的方法

$dateFormatted1 = date("l, M j ", strtotime($day .' '. $preferTime )      );
$dateFormatted2 = date("g:i a", strtotime($day .' '. $preferTime )      );
echo $dateFormmated1 . 'at' $dateFormatted2;

您需要使用反斜杠对字符进行转义。

使用单引号,您需要转义特殊字符(但不是制表符):

date('l, M j 'a't g:i a');

使用双引号,您还需要转义制表符(因此双反斜杠):

date("l, M j 'a''t g:i a");

这对你有用吗?

$dateFormatted = date("l, M j 'a''t g:i a", strtotime($day .' '. $preferTime )      );