gpt4 book ai didi

php - 如何获取当月的所有星期五

转载 作者:行者123 更新时间:2023-12-02 23:17:31 24 4
gpt4 key购买 nike

我有一个问题,

$fridays = array();
$fridays[0] = date('Y-m-d', strtotime('first friday of this month'));
$fridays[1] = date('Y-m-d', strtotime('second friday of this month'));
$fridays[2] = date('Y-m-d', strtotime('third friday of this month'));
$fridays[3] = date('Y-m-d', strtotime('fourth friday of this month'));
$fridays[4] = date('Y-m-d', strtotime('fifth friday of this month'));

但是没有第五个星期五。有些月份有第五个星期五。如何检查而不设置最后一个项目数组?

最佳答案

$fifth = strtotime('fifth friday of this month');

if (date('m') === date('m', $fifth)) {
$fridays[4] = date('Y-m-d', $fifth);
}

关于php - 如何获取当月的所有星期五,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12561562/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com