gpt4 book ai didi

php - 从给定日期 php 获取下个月和上个月的最佳解决方案是什么

转载 作者:行者123 更新时间:2023-12-03 02:16:49 30 4
gpt4 key购买 nike

我想获取给定日期的下个月和上个月。这是我的代码。

$month = '2011-01-20';

$prevMOnth = funP($month);$nextMonth = funN($month);

什么是最好的解决方案。

最佳答案

$next_month_ts = strtotime('2011-01-20 +1 month');
$prev_month_ts = strtotime('2011-01-20 -1 month');

$next_month = date('Y-m-d', $next_month_ts);
$prev_month = date('Y-m-d', $prev_month_ts);

关于php - 从给定日期 php 获取下个月和上个月的最佳解决方案是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8998369/

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