|
Posted by Steve on 03/02/07 14:25
| I'm trying to write a script that works out the day of week, goes back to
| previous Monday, then removes a week and sets up 2 timestamps.
$today = strtotime(date('m/d/Y') . ' 00:00');
$monday = strtotime('last monday', $today);
$monday = strtotime('last monday', $monday);
$sunday = strtotime('next sunday', $monday);
print_r(array(date('D j M y H:i:s a', $monday), date('D j M y H:i:s a',
$sunday)));
| EG, if the day was Wednesday 28 Feb 2007 then is would work out that the
| Monday was the 26, then remove 7 days to give me my start data and add 6
| days to give me my end date. So for Wednesday 28 Feb 2007 I should end up
| with Mon 19th Feb to Sun 26th Feb
you could also do date math with the strtotime function...such as,
strtotime('-7 days', $monday)...i did not do that here as you seem to alway
be looking for the start and end of the week.
hth...let me know how it works. i just wrote it here and haven't debugged
it, so there may be syntax problems.
me
[Back to original message]
|