Jump to content

Date manipulation


dannybrazil

Recommended Posts

Hello,

 

I have a code that adds 1 month to a specific date every month.

$newdate = strtotime ( '+1 month' , strtotime ( $b_date ) ) ;
$new_date = date ( 'Y-m-d' , $newdate );

 

the thing is some month of the year do not contain the SAME amount of days.

 

For example:

 

If the date was 2011-01-31

 

+ 1 month

 

=

 

03-03-2011

 

Is there any way to add a month (+1 month) but make it consider the calendar.

 

lets say that I had 2011-01-31 --> +1 month == 2011-28-02 (the last day of the next month if there is NO similar days in month

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/231852-date-manipulation/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.