note 4840 modified in date by ronabop

From: Date: Fri, 01 Sep 2000 04:30:56 +0000
Subject: note 4840 modified in date by ronabop
Groups: php.notes 
Request: Send a blank email to php-notes+get-3877@lists.php.net to get a copy of this message
I implemented the "week of the year"-script in a rather different way, partly because here in Finland the week starts from monday: (It hasn't been optimized in any way, so cut the laughter back there :I) function weekofyear() { /* array for switching the week to begin from monday instead of sunday */ $week=array(6,0,1,2,3,4,5); $p=$week[date("w",mktime(0,0,0,1,1,date("Y")))]; if($p<4) $start=1-$p; else $start=$p+($p-7); $today=$week[date("w")]; /* no rounding is needed since we always get full weeks */ return(((date("z")-$today+1)-$start)/7+1);} http://www.php.net/manual/function.date.php

« previous php.notes (#3877) next »