|
Posted by Brian on 03/02/07 17:06
"Brian" <brian_no_spam@nrwp.co.uk> wrote in message
news:khYFh.49640$Da4.7880@newsfe6-gui.ntli.net...
>
> Sorry i didn't undersatnd you mean both lines, MANY MANY MANY thanks
> all working :)
>
>
>> $sunday = strtotime('next sunday', $monday);
>> $sunday = strtotime(date('m/d/Y', $sunday) . ' 23:59:59');
>>
Hi Steve (sorry again)
Spoke to soon, I understand what you are doing (well it think so)
and it should work, but the Sunday is not working
Monday is OK so if i have this right this is what is happening
// get the next sunday after the monday we just set
// using the monday to work this out
$sunday = strtotime('next sunday', $monday);
// set the above sunday time to 23:59:59
$sunday = strtotime(date('m/d/Y', $sunday) . ' 23:59:59');
This should work, but if I run it now I get the correct
Monday (Mon 19 Feb 07, 00:00:00 ) but it keeps
setting next Sundays date (Sun 4 Mar 07, 23:59:59)
instead of 25th Feb.
It seems to be ignoring the fact we am saying work out
the next Sunday from the Monday we set
Below is all the code I am using, am I missing something
again?
Brian
$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);
$sunday = strtotime(date('m/d/Y', $sunday) . ' 23:59:59');
// build up some string to view timestamps in real dates
$realstartdate = date("D j M y, H:i:s a", $monday);
$realenddate = date("D j M y, H:i:s a", $sunday);
// print out real dates to make sure dates are correct
echo "Start: $realstartdate ($monday)<br>End: $realenddate ($sunday)
<br>Weeknumber is $weeknumber<br>";
--------------------------------------------------------------------------------
I am using the free version of SPAMfighter for private users.
It has removed 173 spam emails to date.
Paying users do not have this message in their emails.
Try SPAMfighter for free now!
Navigation:
[Reply to this message]
|