RE: beginnind and end of the week

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>-----Original Message-----
>From: Curt Zirzow [mailto:php-general@xxxxxxxxxxxxxxxxx]
>Sent: Monday, 1 November 2004 3:46 p.m.
>To: php-general@xxxxxxxxxxxxx
>Subject: Re:  beginnind and end of the week
>
>* 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

Hmm. Could you simply use the SQL 
"WHERE WEEK(dateinrecord) = WEEK(dateinquestion)"? Or maybe use YEARWEEK to
make sure you match the year too?

Saves re-inventing the wheel...

Tim

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux