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. How can I find/calculate that in PHP? 回答1: 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);