PHP add 1 month to date

后端 未结 6 1372
旧巷少年郎
旧巷少年郎 2020-12-19 15:23

I\'ve a function that returns url of 1 month before.

I\'d like to display current selected month, but I cannot use simple current month, cause when user clicks link

6条回答
  •  渐次进展
    2020-12-19 15:40

    simple method:

    $next_month = strtotime('august 2012 next month');
    

    better method:

    $d = new Date('August 2012');
    $next_month = $d->add(new DateInterval('P1M'));
    

    relevant docs: strtotime date dateinterval

提交回复
热议问题