Add six months in php

后端 未结 4 822
难免孤独
难免孤独 2020-12-03 21:46

I\'m trying to get the month, six months out from the current date.

I\'ve tried using:

date(\'d\', strtotime(\'+6 month\', time()));

B

4条回答
  •  无人及你
    2020-12-03 22:37

    You can use the DateTime class in conjunction with the DateInterval class:

    add(new DateInterval('P6M'));
    
    echo $date->format('d M Y');
    

提交回复
热议问题