note 6532 deleted from Date and Time functions by ronabop
| From: | ronabop@php.net | Date: | Sat, 10 Mar 2001 21:54:53 +0000 |
| Subject: | note 6532 deleted from Date and Time functions by ronabop | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-12187@lists.php.net to get a copy of this message | ||
Quite a long time I was looking for some way to get the exact calendar week (Kalenderwoche) of a
certain date. Might be usefull for somebody else, so here it is:
First calculate the days that went on from the 1st of Jan to the day we're talking of:
$days_before = round((mktime(0,0,0,MM,1,"JJJJ") -
mktime(0,0,0,1,1,"JJJJ"))/86400);
"MM" ist month and "JJJJ" is the year.
(Should work without "round" but did'nt for me ...)
Than get the calendar week ($kw):
$kw = floor((($days_before + ((date("w", mktime(0,0,0,1,1,"JJJJ"))+2) % 7)) -
3) / 7) + 1;
andy