note 29557 deleted from function.date by sniper

From: Date: Sat, 11 Oct 2003 16:52:56 +0000
Subject: note 29557 deleted from function.date by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-58280@lists.php.net to get a copy of this message
Note Submitter: demmer@chello.at ---- i use this to get a unix timestamp from a weeknumber and a year: function weektoday($week,$year){ $day = strtotime($year."-01-01"); $dayofweek = date("w",$day); if($dayofweek != 5 && $dayofweek != 6 && $dayofweek != 0){ while(1 != date("w",$day)){ $day = mktime(0,0,0,date("m", $day),date("d", $day)-1,date("Y", $day)); } } else{ while(1 != date("w",$day)){ $day = mktime(0,0,0,date("m", $day),date("d", $day)+1,date("Y", $day)); } } $day = mktime(0,0,0,date("m", $day),date("d", $day)+7*$week-7,date("Y", $day)); return $day; } monday is the first day of a week and a week with 4 days in the new year counts as week 1.

« previous php.notes (#58280) next »