|
Posted by Steve on 03/02/07 14:46
"Steve" <no.one@example.com> wrote in message
news:nvWFh.6$0P1.0@newsfe06.lga...
|| 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)));
rik brought up a good point. if $today is monday, do you want the monday 2
weeks ago or just one. while i love date math, i think this may be more
understandable for the novice:
$today = strtotime(date('m/d/Y') . ' 00:00');
$monday = strtotime('last monday', $today);
if (intval(strftime('%w', $monday)) != 0)
{
$monday = strtotime('last monday', $monday);
}
$sunday = strtotime('next sunday', $monday);
[Back to original message]
|