How to increase date by one month from fetched date from the database in php


I want to increase date by one month but if we give current date is working but i want to increase date by nest month from the database fetched date

I tried like but it is not working

 $onemonth = date($regdate,  strtotime("+1 month")); 

How to add $regdate variable to date function…?


Which format is $regdate?


Assuming you have a proper date column…

SELECT DATE_ADD(“created_date”, INTERVAL 1 Month) AS onemonth;


Field 1 of date is the format (e.g. for dd-mm-yyyy it will need to be ‘d-m-Y’)
Field 2 will expect the date as a timestamp (e.g. strtotime( $regdate . ’ +1 month’) )

NOTE: This expects $regdate to be in the format YYYY-MM-DD
NOTE: +1 month will just change the month (e.g. March 31st +1 month = April 31st - which doesn’t exist)


No. The date math that php does rolls over into the following month. March 31st + 1 month results in May 1st.