gpt4 book ai didi

php - 使用 strtotime 忽略/跳过周末

转载 作者:行者123 更新时间:2023-11-29 03:58:16 25 4
gpt4 key购买 nike

我在 while 语句中使用 strtotime 来自动更新数据库中的条目。

它会根据用户在上一页中的陈述增加天数。

使用这段代码:

    $calendardate = strtotime ( '+'.$calendarday.' day' , strtotime ( $date ) ) ;
$calendardate = date ( 'Y-m-d' , $calendardate );

如何让它跳过周末?我需要使用相同的变量($calendardate),但我需要它来忽略周六和周日。

非常感谢任何帮助:)

最佳答案

$now = date("Y-m-d H:i:s");
$h = date("H:i:s");
$two_weekdays_later = strtotime(date("Y-m-d H:i:s", strtotime($now)) . " +2 weekdays $h");

关于php - 使用 strtotime 忽略/跳过周末,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7189733/

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