-5

Possible Duplicate:
php strtotime “last monday” if today is monday?

I want to get some information from the database from this current week.

So what do i need? The first monday (date) and the next sunday (date).

This code works fine, but:

$fm = date('Y-m-d', strtotime('last monday', time()));
$lz = date('Y-m-d', strtotime('next sunday', time()));

But when it IS monday this doesnt work? It gives me a total different date.

What can i do to prevent this?

Community
  • 1
  • 1
Kenny
  • 144
  • 1
  • 2
  • 9
  • Please give exmaples of 1. what you expect. 2. what you are getting. possibly too why you expect what etc. I'm not sure why you didn't think, after writing "it gives me a total different date" to actually tell us _what_ date you are getting? – Nanne Oct 23 '12 at 08:26
  • What does this have to do with "the database" or "SQL"? – Colin 't Hart Oct 23 '12 at 09:11

1 Answers1

0

Sorry didnt search good enough.

$eerstedag = date('Y-m-d', strtotime('last monday', time()));
if (date('N', time()) == 1) $eerstedag =  date('Y-m-d');
else $eerstedag = date('Y-m-d', strtotime('last Monday'));

This works for me.

Kenny
  • 144
  • 1
  • 2
  • 9