📌  相关文章
📜  php 获取一个月内的所有星期六 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:13.292000             🧑  作者: Mango

代码示例1
function getSundays($y, $m) {
    return new DatePeriod(
        new DateTime("first sunday of $y-$m"),
        DateInterval::createFromDateString('next sunday'),
        new DateTime("last day of $y-$m")
    );
}

// Usage:
foreach (getSundays(2021, 03) as $sundays) {
    echo $sundays->format("l, Y-m-d\n");
}