如何查询两个日期之间的星期二或星期二? [英] how to find number of mondays or tuesdays between two dates?
本文介绍了如何查询两个日期之间的星期二或星期二?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有开始日期和结束日期。
I have start date and end date.
我需要找出星期天或星期一等等,这取决于用户点击复选框。
I need to find out the day that is Sunday or Monday etc dependent upon user click on check box.
如何在PHP中查找/计算?
How can I find/calculate that in PHP?
推荐答案
您可以创建一个使用strtotime()递归计算天数的函数。由于 strtotime(next monday);
工作正常。
You could create a function that uses strtotime() recursively to count the number of days. Since strtotime("next monday");
works just fine.
function daycount($day, $startdate, $counter)
{
if($startdate >= time())
{
return $counter;
}
else
{
return daycount($day, strtotime("next ".$day, $startdate), ++$counter);
}
}
echo daycount("monday", strtotime("01.01.2009"), 0);
希望这是您要找的东西:)
Hopefully this is something you're looking for :)
这篇关于如何查询两个日期之间的星期二或星期二?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文