I have such a line - the current date + 7 days:
$ nextweek = date (mktime (date ("m"), date ("d") + 7, date ("Y")));

It is necessary to translate the result in the form '2016-02-19' How to do it?

  • php.net/manual/ru/function.date.php you would have your date as the first parameter directly set the mask for which to give - Mike
  • I did this: $ nextweek = date ("Ymd", mktime (date ("m"), date ("d") + 7, date ("Y"))); Displays in the correct format, but shows the current day The 12th, but the 19th is needed - amijin
  • php.net/manual/ru/function.mktime.php the first 3 arguments take hours of minutes and seconds, and then a month a day a year, so mktime (0,0,0, date ("m"), date ("d ") +7, date (" Y ")) - Mike

2 answers 2

The current date is 7 days shorter to receive so:

date("Ymd",time()+7*24*60*60); 

Using mktime like this:

 date("Ymd",mktime(0,0,0,date("m") , date("d")+7, date("Y"))); 

    The first parameter is the format, the second is your date. date('Ym-d', $date);