|
Posted by Brian on 03/02/07 15:03
Hi All
I should have made this a little clear, I need to end up with 2 timestampes
and not the formatted time, $realstartdate and $realenddate are just
for visuals
thanks for all your replies, now just got to work out want they all mean :)
Brian
"Brian" <brian_no_spam@nrwp.co.uk> wrote in message
news:6bWFh.32587$s47.8173@newsfe4-gui.ntli.net...
>
>
> 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!
>
>
>
--------------------------------------------------------------------------------
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]
|