In PHP, how to know how many mondays have passed in this month uptil today?
问题 Assume today is Feb 21, 2011 ( Monday ). It is the third Monday of this month. If date is given as input, How can I know how many Mondays have passed before it? In PHP, how to know how many mondays have passed in this month uptil today? 回答1: $now=time() + 86400; if (($dow = date('w', $now)) == 0) $dow = 7; $begin = $now - (86400 * ($dow-1)); echo "Mondays: ".ceil(date('d', $begin) / 7)."<br/>"; works for me.... EDIT: includes today's monday too 回答2: That sounds like a pretty straightforward