Reputation: 15950
Basically, my question is about finding date-ranges
From today's date [ using date() ], I want to find
starting and ending date for current week
Let's assume
Today: 14 July, 2011
start of week: 10 July, 2011
end of week: 16 July, 2011
starting and ending date for current month
Let's assume
Today: 14 July, 2011
start of month: 1 July, 2011
end of month: 31 July, 2011
How can I find these dates ?
Upvotes: 0
Views: 87
Reputation: 522025
$firstOfTheMonth = date('1 F Y');
$lastOfTheMonth = date('t F Y');
$startOfTheWeek = date('j F Y', mktime(0, 0, 0, date('n'), date('j') - date('w')));
$endOfTheWeek = date('j F Y', mktime(0, 0, 0, date('n'), date('j') - date('w') + 6));
All the different parameters for date
basically give you all you need, the rest is a tiny bit of math.
Upvotes: 3