How do I get next month date from today's date and insert it in my database?

后端 未结 13 562
我寻月下人不归
我寻月下人不归 2021-02-01 15:07

I have two columns in my db: start_date and end_date, which are both DATE types. My code is updating the dates as follows:



        
13条回答
  •  礼貌的吻别
    2021-02-01 15:11

    I think this is similar to kouton's answer, but this one just takes in a timeStamp and returns a timestamp SOMEWHERE in the next month. You could use date("m", $nextMonthDateN) from there.

    function nextMonthTimeStamp($curDateN){ 
       $nextMonthDateN = $curDateN;
       while( date("m", $nextMonthDateN) == date("m", $curDateN) ){
          $nextMonthDateN += 60*60*24*27;
       }
       return $nextMonthDateN; //or return date("m", $nextMonthDateN);
    }
    

提交回复
热议问题