ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
## 时间处理 ```php $d1 = '2020-04-28'; $d2 = '2020-06-28'; // echo date('Y-m-t', strtotime("+30 days", strtotime($d1)));exit; // echo date('Y-m-t', strtotime("+1 month", strtotime($d1)));exit; // echo date('Y-m-t', strtotime("+3 days", strtotime($d1)));exit; // +1 days 此时慎用 strtotime modify 处理时间,遇跨月时处理不符合常规直观。DateTime 是符合直观的。感觉 strtotime 存在bug $d = new DateTime($d1); $d->modify('+30 days'); echo $d->format('Y-m-d'); exit; ``` ### 参考 https://www.laruence.com/2018/07/31/3207.html [https://www.php.net/manual/en/function.strtotime.php](https://www.php.net/manual/en/function.strtotime.php) [https://derickrethans.nl/obtaining-the-next-month-in-php.html](https://derickrethans.nl/obtaining-the-next-month-in-php.html)