Re: beginnind and end of the week
| From: | Jerry Swanson | Date: | Tue, 02 Nov 2004 11:49:00 +0000 |
| Subject: | Re: beginnind and end of the week | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-200911@lists.php.net to get a copy of this message | ||
Your solution works only for Monday. For Tuesday output is below
start -- 20041108
end - 20041114
I have no idea why ti doesn't wotk.
On Mon, 1 Nov 2004 02:45:59 +0000, Curt Zirzow
<php-general@zirzow.dyndns.org> wrote:
> * Thus wrote Jerry Swanson:
>
>
> > I need to run a query using PHP/MYSQL. The query should be for a week.
> > So if today is tuesday, the query should be from Monday to Sunday.
> > How in in php I can know when the beginning and end of the week?
> >
>
> <?php
>
> // in case the date unlikley changes
> $t = time();
>
> // this weeks monday
> $m = strtotime('this monday', $t);
>
> // next weeks monday minus 1 second
> $s = strtotime('next monday', $t) - 1;
>
> echo date('r', $m), "\n";
> echo date('r', $s), "\n"
>
> ?>
>
> Now $m and $s contain the proper timestamps.
>
> Curt
> --
> Quoth the Raven, "Nevermore."
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>