指定月份的第某个月

最后更新于:2022-04-02 02:19:02

[TOC] ### 函数 ``` function getAfterMonth($newMonth, $num){ $nowMonth = date('Y-m-d H:i:s', strtotime($newMonth."01")); $timestamp = strtotime("{$nowMonth} -$num month"); $newMonth = date('Ym', $timestamp); return $newMonth; } echo getAfterMonth('202001','0').PHP_EOL; // 202001 echo getAfterMonth('202001','1').PHP_EOL; // 201912 echo getAfterMonth('202001','2').PHP_EOL; // 201911 ```
';