Re: [PHP3] Days in a week
| From: | (Richard Lynch) | Date: | Fri, 16 Jun 2000 00:43:47 +0000 |
| Subject: | Re: [PHP3] Days in a week | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-2015@lists.php.net to get a copy of this message | ||
In article <0057440001201369000002L492*@MHS>,
Gregor.Zurowski@daimlerchrysler.com wrote:
> =0AHello,
>
> I have saves week numbers in a database and I want to have a function w=
> hich
> gives me the exact days in this weeks (eg. week 2/2000; days: 10.1.,11=
> .1, ...,
> 16.1.).
Some combination of calls to date() and mktime() should do it...
It kind of depends what you mean when you say "week number", and what you
do with a partial week, or...
Here's a rough idea (untested):
$weekyear = "2/2000";
$weekyear = explode('/', $weekyear);
$week = $weekyear[0];
$year = $weekyear[1];
$daynumber = $week * 7;
//Note that January 32 is wrapped properly to Feb 1.
//January 365 is December 31st, except in a leap year.
//mktime() knows. mktime() smart.
$date = date(0, 0, 0, 1, $daynumber, $year);
//Now the question is if you want Sun-Sat
//or just start on that date and go up, or???
for ($day = 0; $day < 7; $day++){
echo date("M/d/Y", $date + $day);
}
--
Richard Lynch | If this was worth $$$ to you, buy a CD
US Customer Support Director | from one of the artists listed here:
Zend Technologies USA | http://www.L-I-E.com/artists.htm
http://www.zend.com | (this has nothing to do with Zend,
duh!)