views:

205

answers:

2

In php i can get today date/day by using : $today = date('D, Y-m-d');

If today is wednesday 8 july, i want to display data from 6 - 11 July (9, 10 and 11 will be blank). How do I do that?

Now my system is like, today is 8 July, i will display 2 - 8 july, but start on wednesday. Not very like this way. I prefer, start on Monday to sunday, then have previous and next week button.

+2  A: 

Use simple strtotime() to easy calculate the date of last monday.

$lastMonday = strtotime('last monday');

Be sure to check if today is not monday, because in that case it will return a date week earlier.

Maciej Łebkowski
how about next and previous button thing??
jingleboy99
that's easy as - strtotime('next monday');
Ish Kumar
okay.. thanks for the answer
jingleboy99
A: 
... WHERE  YEARWEEK( $inputdate ) = YEARWEEK( datefield) ...

http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_yearweek

rooskie