note 33497 deleted from function.mktime by stone

From: Date: Sat, 28 Jun 2003 20:58:50 +0000
Subject: note 33497 deleted from function.mktime by stone
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-51139@lists.php.net to get a copy of this message
Note Submitter: marc@grue.REMOVE.info ---- To calculate the date of the first day in a week from a given $year and $week_number (ex week 2 of 2003): function week_date_unix ($year, $week_number) { // Numeric day of the week for the 1st of January, $year $no = date("w", mktime(0,0,0,1,1,$year)); // First day of first week in $year $first_day = mktime(0,0,0,1,1,$year) - ($no-1) * 86400; // Add $week weeks to first day return strtotime("$week_number weeks", $first_day); } Returns the monday in that week as a UNIX timestamp (ex 1041807600 = 6th of January 2003).

« previous php.notes (#51139) next »