note 105462 deleted from function.date by tularis

From: Date: Thu, 09 Feb 2012 20:50:04 +0000
Subject: note 105462 deleted from function.date by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-185951@lists.php.net to get a copy of this message
Note Submitter: Chris ---- Convert a week number to a date: <?php $year = 2011; $week_num_correction = strftime('%U', mktime(0,0,0,1,1,$year)) === '00' ? 1 : 0; for($week = 1; $week < 54; $week++) { $begin = strtotime("this sunday +".(($week-1)-$week_num_correction)." weeks", mktime(0,0,0,1,1,$year)); echo "week $week of $year starts on ", date('M j Y', $begin); } ?> The "week_number_correction" is to convert from ISO week #'s to US week numbers (weeks begin on Sunday, 1st day is first week).

« previous php.notes (#185951) next »