Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个变量$date='15-06-2013'。现在,我如何获得一周中的天数?15-06-2013 是一个,因此如果我要使用格式字符Saturday,我的函数应该作为数字返回6N
$date='15-06-2013'
Saturday
6
N
使用此代码
echo $day_of_week = date('N', strtotime('15-06-2013'));
或者,使用DateTime类:-
echo (new \DateTime('15-06-2013'))->format('N');
输出:-
看到它工作