Re: PEAR::Calendar: Can you build a week with only the year and the week number
| From: | Andre Gemünd | Date: | Fri, 23 Jul 2004 14:00:19 +0000 |
| Subject: | Re: PEAR::Calendar: Can you build a week with only the year and the week number | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-13828@lists.php.net to get a copy of this message | ||
Peter Monsson wrote:
but that's not possible (yet) so I'm wondering whether there is an other way to achieve the same result without having to iterate through the whole year.You can easily calculate the date out of the weeknumber, just get the first thursday of the year decrement until its monday and add 7*(weeknr-1) to it. $year = 2004; $offset = date('w', mktime(0,0,0,1,1,$year)); $offset = ($offset < 5) ? 1-$offset : 8-offset; $monday = mktime(0,0,0,1,1+$offset,$year); Regards André