-1

I need to get an array with all dates of the last week - for example, if it is 02.06.2018 today, i have to get 02.06, 01.06, 31.05, 30.05, 29.05, 28.05, 27.05. It must consider month number and amount of days in the month. Is there any simple way to do this?

  • Please check out this question: https://stackoverflow.com/questions/4312439/php-return-all-dates-between-two-dates-in-an-array ...and replace the dates to your needs. – mixable Jun 01 '18 at 23:05

1 Answers1

2

See if this works for you:

for($i = 0; $i < 7; $i++){

$myDates[] = date('d.m', strtotime(date('Y-m-d') . ' - ' . $i . ' days'));

}

print_r($myDates);
Joseph_J
  • 3,654
  • 2
  • 13
  • 22