note 4840 deleted from date by ronabop

From: Date: Sat, 10 Mar 2001 23:01:39 +0000
Subject: note 4840 deleted from date by ronabop
Groups: php.notes 
Request: Send a blank email to php-notes+get-12218@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);}

« previous php.notes (#12218) next »