|
Posted by Steve on 03/02/07 15:27
"Brian" <brian_no_spam@nrwp.co.uk> wrote in message
news:Q9XFh.41373$Fm2.13741@newsfe1-gui.ntli.net...
|
| "Rik" <luiheidsgoeroe@hotmail.com> wrote in message
| news:op.tokf4812qnv3q9@misant...
| > Does it go back to the previous Monday if the current day is a Monday?
|
| Yes always the week before, so even if it's Monday still go back a week,
if
| it;s
| Wednesday, then go back 1 week and 2 days
|
| I need to end up with 2 timestamps from the priviose week starting on the
| monday
| at 00:00:00 and ending on the Sunday at 23:59:59
so whatever today is, get the date of last week's monday. this is the start
date. from there, the following sunday is the end date...right?
$today = strtotime(date('m/d/Y') . ' 00:00');
$monday = strtotime('last monday', $today);
// at this point, $monday is either the monday of the same
// week as $today or, it is the monday of the week prior
// to the week of $today
// find out here:
if (intval(strftime('%w', $today)) != 0)
{
// $today is NOT monday, so we need to get
// last week's monday
$monday = strtotime('last monday', $monday);
}
// either way, sunday is determined by $monday
$sunday = strtotime('next sunday', $monday);
make sense? your start date is now $monday and, your end date is $sunday.
this tries to use text-based to help it be more easily understood. if you
like the brevity of date math, go for it.
hth,
me
[Back to original message]
|