0

I have a number and I want to increase the month of date so if the date is 2016-01-01 will return 2016-04-01

$month = 3;
$date = date('Y-m-d', strtotime(str_replace('/', '-', $this->input->post('date'))));
Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
Mina Magdy
  • 141
  • 1
  • 15
  • 2
    Possible duplicate of [Adding three months to a date in PHP](http://stackoverflow.com/questions/9875076/adding-three-months-to-a-date-in-php) – Let'sRefactor Jan 25 '16 at 18:26

2 Answers2

1

Untested, But you could do something like:

$month = 3;
$newdate = date('Y-m-d', strtotime("+".$month." months", str_replace('/', '-', $this->input->post('date'))));
Dave
  • 1,049
  • 10
  • 6
1

You can add three months in a given date by using this:

$Date = date('Y-m-d', strtotime("+3 months", strtotime(str_replace('/','-', $this->input->post('date') ))));
devpro
  • 16,184
  • 3
  • 27
  • 38