note 19511 rejected from function.date by hholzgra

From: Date: Sat, 13 Apr 2002 18:20:00 +0000
Subject: note 19511 rejected from function.date by hholzgra
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-29222@lists.php.net to get a copy of this message
I couldn't find any function that returned start date of a given week and year, so I made this: function get_date_from_week($year, $week) { $first_day = strtotime($year."-01-01"); $is_monday = date("w", $first_day) == 1; $is_weekone = strftime("%V", $first_day) == 1; if($is_weekone) { $week_one_start = $is_monday ? strtotime("last monday", $first_day) : $first_day; } else { $week_one_start = strtotime("next monday", $first_day); } return $week_one_start+(3600*24*7*($week-1)); }

« previous php.notes (#29222) next »