note 29557 added to function.date

From: Date: Mon, 17 Feb 2003 16:43:16 +0000
Subject: note 29557 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-44101@lists.php.net to get a copy of this message
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. -- http://www.php.net/manual/en/function.date.php http://master.php.net/manage/user-notes.php?action=edit+29557 http://master.php.net/manage/user-notes.php?action=delete+29557 http://master.php.net/manage/user-notes.php?action=reject+29557

« previous php.notes (#44101) next »