【发布时间】:2017-04-06 07:28:15
【问题描述】:
所以我试图计算一个月中的周数,包括第 1 天是星期天或星期六而第 31 天是星期一的可能性,这意味着该月将有 6 周。 到目前为止,我得到了这个:
<?php
for ($Month = 1; $Month <= 12; $Month++)
{
if ($rstFase->fields['StartMonth'] <= $Month)
{
?>
<div class="mounthDate">
<?php
$timestamp = mktime(0, 0, 0, $x, 1, $i);
while (date('n', $timestamp) == $x)
{
?>
<div class="week"></div>
<?php
$timestamp = strtotime("+1 week", $timestamp);
}
?>
</div>
<?php
}
else
{
?>
<div class="mounthDate"></div>
<?php
}
}
所以正确计算有 4 或 5 周的月份,但例如 2017 年 7 月有 6 个,它算作 5 个。
有什么想法吗?
【问题讨论】: