🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
## 时间处理 ```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)