-4

I am designing a software for leave management in php.I actually need a simple function in php which takes a given date as parameter(i.e any date) and no of days to be added to it as the parameter and returns the resultant date.

The function should accept date in 'YYYY-MM-DD' format and also return resulting date in same mentioned format.

I need help.Any help will be highly appreciated in this regard.

shripati007
  • 87
  • 1
  • 2
  • 13
  • 7
    Please review the list of duplicate questions under the **Related** header to the right. Any of the answers mentioning `strtotime` will apply to this question. [There are only **two thousand** of them](http://stackoverflow.com/search?q=%5Bphp%5D+strtotime). – Charles May 12 '11 at 06:22

1 Answers1

2

As simple as:

echo date('Y-m-d', strtotime('2011-05-12') + (60 * 60 * 24 * $days));

or:

echo date('Y-m-d', strtotime("+$days days", strtotime('2011-05-12')));
deceze
  • 510,633
  • 85
  • 743
  • 889
  • 2
    @shri No problem, but you really should search the PHP manual and/or Stackoverflow first next time. Questions about date/time manipulation are about the most often asked ever. – deceze May 12 '11 at 06:30