如何计算从当前YEAR到今天已经过的星期日数.我还想计算从当前MONTH到今天已经过的星期日数.
例如
today is 14 April 2012 I should get 2 for the Number of Sundays
that are passed from the current month.
Run Code Online (Sandbox Code Playgroud)
任何人都可以给我一个提示或教程如何实现这一目标?
嗯,我想使用date()函数很简单
//will give you the amount of sundays from the begining of the year
$daysTotal = ceil((date("z") - date("w")) / 7);
//will give you the amount of sundays from the begining of the month
$daysTotal = ceil((date("j") - date("w")) / 7);
Run Code Online (Sandbox Code Playgroud)
我没有测试它,你可能想检查round()函数是否在这种情况下正常工作但我认为这个点已经过了
祝好运
| 归档时间: |
|
| 查看次数: |
1450 次 |
| 最近记录: |