note 19511 added to function.date
| From: | bjorn at noname4us dot com | Date: | Fri, 01 Mar 2002 13:11:43 +0000 |
| Subject: | note 19511 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-27224@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));
}
--
http://www.php.net/manual/en/function.date.php
http://master.php.net/manage/user-notes.php?action=edit+19511
http://master.php.net/manage/user-notes.php?action=delete+19511
http://master.php.net/manage/user-notes.php?action=reject+19511