2
My first post here, so if you type anything wrong, I apologize.
My problem is this: I use a method in PHP to add a date to a number x of months. For example:
2017-01-01
+ 11 months
expected result:
2017-12-01
.
But I need something that besides bringing the month together, that also brings the last day of the month.
For example:
2017-01-0 + 11 meses = 2017-12-31
.
Do you realize that the number of days came with the last day of December month together? So, I need this.
To $data1
will always start with day 01, regardless of the year/month that will be sought.
I am currently using this code to add the number of months to the date:
public static function SomarDataMes($data, $meses){
$data = explode("/", $data);
$newData = date("d/m/Y", mktime(0, 0, 0, $data[1] + $meses, $data[0], $data[2]) );
return $newData;
}