0
我想在网站上自动显示每个月的第一个和第三个星期一。如果当前日期在第一个星期一之后,则仅显示第三个星期一。获取每月的第一个和第三个星期一 - strtotime
我修改了在论坛上发现的代码并做了一些更改,但由于有限的php知识,我无法验证它是否会提供正确的结果。
$time = strtotime("first Monday of ".$monthname." ".$year);
$time2 = strtotime("third Monday of ".$monthname." ".$year);
{
if ($time2 > $time) {
echo date('d-m-Y',$time2)." ".$monthname;
}
else {
echo date('d-m-Y',$time)." ".$monthname;
}
}