note 69536 added to function.strtotime
| From: | craig at datafathom dot com | Date: | Sat, 09 Sep 2006 07:35:08 +0000 |
| Subject: | note 69536 added to function.strtotime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-116952@lists.php.net to get a copy of this message | ||
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;
}
?>
----
Server IP: 216.194.113.175
Probable Submitter: 68.11.113.156
----
Manual Page -- http://www.php.net/manual/en/function.strtotime.php
Edit -- https://master.php.net/note/edit/69536
Del: integrated -- https://master.php.net/note/delete/69536/integrated
Del: useless -- https://master.php.net/note/delete/69536/useless
Del: bad code -- https://master.php.net/note/delete/69536/bad+code
Del: spam -- https://master.php.net/note/delete/69536/spam
Del: non-english -- https://master.php.net/note/delete/69536/non-english
Del: in docs -- https://master.php.net/note/delete/69536/in+docs
Del: other reasons-- https://master.php.net/note/delete/69536
Reject -- https://master.php.net/note/reject/69536
Search -- https://master.php.net/manage/user-notes.php