Skip to content
Advertisement

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

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:

JavaScript

What is the best way to make $end_date equal to $start_date + one month? For example, 2000-10-01 would become 2000-11-01.

Advertisement

Answer

You can use PHP’s strtotime() function:

JavaScript

Just note that +1 month is not always calculated intuitively. It appears to always add the number of days that exist in the current month.

JavaScript

Some other date/time intervals that you can use:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement