increment date by one month

前端 未结 18 2516
广开言路
广开言路 2020-11-27 04:14

Let\'s say I have a date in the following format: 2010-12-11 (year-mon-day)

With PHP, I want to increment the date by one month, and I want the year to be automatica

18条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-27 04:42

    Please first you set your date format as like 12-12-2012

    After use this function it's work properly;

    $date =  date('d-m-Y',strtotime("12-12-2012 +2 Months");
    

    Here 12-12-2012 is your date and +2 Months is increment of the month;

    You also increment of Year, Date

    strtotime("12-12-2012 +1 Year");
    

    Ans is 12-12-2013

提交回复
热议问题