note 69536 deleted from function.strtotime by derick

From: Date: Sun, 24 Sep 2006 11:38:06 +0000
Subject: note 69536 deleted from function.strtotime by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-117493@lists.php.net to get a copy of this message
Note Submitter: craig at datafathom dot com ---- This function will determine the timestamps starting with Sunday and ending on Saturday for that particular week that contains the date specified. For example, I have a day 2006-09-05 or Sep 5, 2006 and I need to find out the timestamps for that entire week. Using that day, the following would result in an array containing timestamps for the following dates: date timestamp Sep 03 2006 1157259600 Sep 04 2006 1157346000 Sep 05 2006 1157432400 Sep 06 2006 1157518800 Sep 07 2006 1157605200 Sep 08 2006 1157691600 Sep 09 2006 1157778000 <? function getWeekDates($input_date) { $week_number = date("w", strtotime($input_date)); $input_timestamp = strtotime($input_date); for ($i=0; $i < 7; $i++) { if ($i <= $week_number) { $multiplier = $i - $week_number; $timestamps[$i] = strtotime("$multiplier days", $input_timestamp); } else { $multiplier = $i - $week_number; $timestamps[$i] = strtotime("+$multiplier days", $input_timestamp); } } return $timestamps; } ?>

« previous php.notes (#117493) next »