|
Posted by Brian on 03/02/07 14:05
Hi all
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.
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
I have hit a problem, the way I am working it out all goes wrong at the
beginning of the month, bacuse of this
if ($daynum > 1) {
$d = $d - $daynum + 1;
}
Any ideas how I can do this?
$d = date("d"); // 01 to 31
$m = date("m"); // 01 through 12
$y = date("Y"); // 2006
$daynum = date("w");
if ($daynum > 1) {
$d = $d - $daynum + 1;
}
$d = $d - 7;
$startdate = mktime(0, 0, 0, $m,$d,$y);
$weeknumber = date("W", $startdate); // eg 6
$d = $d+6;
$m = date("m");
$y = date("Y");
$enddate = mktime(23, 59, 59, $m,$d,$y);
$realstartdate = date("D j M y H:i:s a", $startdate);
$realenddate = date("D j M y H:i:s a", $enddate);
Cheers
Brian
--------------------------------------------------------------------------------
I am using the free version of SPAMfighter for private users.
It has removed 168 spam emails to date.
Paying users do not have this message in their emails.
Try SPAMfighter for free now!
Navigation:
[Reply to this message]
|