日期 php 格式化日小写

Date php format day lowercase

在 php 文档中我发现:

l (lowercase 'L') A full textual representation of the day of the week Sunday through Saturday (http://php.net/manual/en/function.date.php)

但是

的结果
$d = new \Datetime();
echo $d->format('l');
echo '     ';
echo $d->format('L');

是:

Friday 0

在 php 5.5.18 和 5.3.29

中测试

这是 php 错误吗?还是我做错了什么?

不是bug,L(大写)代表是否闰年

输出正确:

$d->format('l'); returns Friday:

A full textual representation of the day of the week. Sunday through Saturday

$d->format('L') returns 0:

Whether it's a leap year. 1 if it is a leap year, 0 otherwise.

这不是php中的错误,你误会了。

$d->format('L');

returns 1 如果当前年份是闰年,如果不是 returns 0.

L parameter denotes Whether it's a leap year. It will return 1 if it is a leap year, 0 otherwise.

l returns A full textual representation of the day of the week

您误解了 DateTime's 手册页 -

"w" format char is for day of the week
"L" is for leap year.

http://3v4l.org/UC4Tj 提供正确的结果 ("Friday 5") 因为 PHP 5.2