如何在DateTime中获取星期几?
我找不到从DateTime获取星期几的方法。 可以是数字或字符串,都可以。
$today = new DateTime("today");
echo $ today->//whatever to get Friday, Monday or 5, 0
如何在DateTime中获取星期几?
编辑: 我使用的是DateTime,而不是日期。
答案 0 :(得分:0)
您可以使用format()函数
$today->format('l') //Sunday through Saturday
$today->format('w') //0 (for Sunday) through 6 (for Saturday)