0

Any way to take a date like this 2013-05-29 in PHP and get the date (in the same format) of that weeks monday? So the output would be like this: 2013-05-27

watzon
  • 2,401
  • 2
  • 33
  • 65

1 Answers1

7
date('Y-m-d', strtotime('last sunday +1 day', strtotime('2013-05-29')));

last sunday +1 day because last monday would return the Monday of the previous week if $timestamp actually was a Monday already.

And parsing of the original date value 2013-05-29 in a second step because all together as one argument does not work well (mixing of absolute and relative date values is something strtotime does not like very much).

CBroe
  • 91,630
  • 14
  • 92
  • 150