note 35046 modified in function.mktime by vincent
| From: | vincent@php.net | Date: | Thu, 25 Sep 2003 18:24:11 +0000 |
| Subject: | note 35046 modified in function.mktime by vincent | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-57133@lists.php.net to get a copy of this message | ||
The function by marc at grue dot info doesn't work properly with every year. Here is a better
one, which adapts to ISO-8601. It can compute a timestamp by a given $year and $week of that $year:
function week_to_time($week, $year, $day = 0){
return mktime(0, 0, 0, 1, 4 - date('w', (mktime(0, 0, 0, 1, 4, $year) -
1)) + $day, $year) + 604800 * ($week - 1);
}
--was--
The function by marc at grue dot info doesn't work properly with every year. Here is a better
one, which adapts to ISO-8601. It can compute a timestamp by a given $year and $week of that $year:
function week_to_time($week, $year){
return mktime(0, 0, 0, 1, 4 - date("w", (mktime(0, 0, 0, 1, 4, $year) - 1)), $year) +
604800 * ($week - 1) - 3600;
}
http://www.php.net/manual/en/function.mktime.php