在PHP中,如何知道本月有多少个星期过去? [英] In PHP, how to know how many mondays have passed in this month uptil today?

查看:103
本文介绍了在PHP中,如何知道本月有多少个星期过去?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设今天是2011年2月21日(星期一)。这是本月的第三个星期一。如果日期作为输入,我如何知道星期一之前已经过了多少?



在PHP中,如何知道本月有多少个月通过今天上涨?

解决方案

  $ now = time()+ 86400; 
if(($ dow = date('w',$ now))== 0)$ dow = 7;
$ begin = $ now - (86400 *($ dow-1));

echo星期一:.ceil(date('d',$ begin)/ 7)。< br />;

为我工作....



编辑:包括今天的星期一


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?

解决方案

$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

这篇关于在PHP中,如何知道本月有多少个星期过去?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆