jon*_*ohn 25
$newDate = strtotime('+1 month',$startDate);
Run Code Online (Sandbox Code Playgroud)
使用strtotime()你可以传递'+1个月'来添加一个上下文敏感的月份.
我会使用该strtotime()函数,添加+1 month到您的时间戳:
$future = strtotime('+1 month', $current_time);
Run Code Online (Sandbox Code Playgroud)
有了strtotime(),你不必考虑自己"像一个月30天,其他人有31",或"2月有时有28天,有时29".
毕竟,添加一个月到一个日期有点困难,添加30*24*3600秒......
您也可以使用DateTime类和方法,如DateTime::modify()或DateTime::add().
| 归档时间: |
|
| 查看次数: |
24796 次 |
| 最近记录: |