note 17943 deleted from ref.datetime by jimw
| From: | jimw@php.net | Date: | Fri, 11 Jan 2002 21:46:28 +0000 |
| Subject: | note 17943 deleted from ref.datetime by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-24707@lists.php.net to get a copy of this message | ||
The following function returns the correct timestamp from any given Weeknumber + Year + Day.
Weeknumber can be 1 - 53 where week 1 is the first week in the year having at least 4 days. This is
the definition of weeknumbers that is used in the Netherlands, im not sure which countries use the
same calculation method. Day should be in range of 1 (monday) till 7 (sunday).
function WkToDate($wknr, $yr, $day = 1)
{ $min_days = (strftime("%u", mktime(0, 0, 0, 1, 1, $yr)) > 4?-7 +
strftime("%u", mktime(0, 0, 0, 1, 1, $yr)):strftime("%u", mktime(0, 0, 0, 1, 1,
$yr)));
$offset = ($wknr - 1) * 7 + $day - $min_days;
return mktime($offset * 24, 0, 0, 1, 1, $yr);
};