note 33497 added to function.mktime
| From: | marc at grue dot REMOVE dot info | Date: | Fri, 27 Jun 2003 17:41:09 +0000 |
| Subject: | note 33497 added to function.mktime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-51109@lists.php.net to get a copy of this message | ||
To calculate the date of the first day in a week from a given $year and $week_number (ex week 2 of
2003):
function week_date_unix ($year, $week_number) {
// Numeric day of the week for the 1st of January, $year
$no = date("w", mktime(0,0,0,1,1,$year));
// First day of first week in $year
$first_day = mktime(0,0,0,1,1,$year) - ($no-1) * 86400;
// Add $week weeks to first day
return strtotime("$week_number weeks", $first_day);
}
Returns the monday in that week as a UNIX timestamp (ex 1041807600 = 6th of January 2003).
----
Manual Page -- http://www.php.net/manual/en/function.mktime.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+33497
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+33497&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+33497&report=yes