note 17943 added to ref.datetime
| From: | php-general at lists dot php dot net | Date: | Fri, 04 Jan 2002 13:16:51 +0000 |
| Subject: | note 17943 added to ref.datetime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-24390@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);
};
--
http://www.php.net/manual/en/ref.datetime.php
http://master.php.net/manage/user-notes.php?action=edit+17943
http://master.php.net/manage/user-notes.php?action=delete+17943
http://master.php.net/manage/user-notes.php?action=reject+17943