note 9820 deleted from ref.datetime by victor
| From: | victor@php.net | Date: | Mon, 09 Dec 2002 18:49:12 +0000 |
| Subject: | note 9820 deleted from ref.datetime by victor | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-40605@lists.php.net to get a copy of this message | ||
Function 'wend'
Pass to: A number representing the week of the year ($wkno).
Uses: $t - the current time and return value
$dx - the current day of the week (0-6)
$woy - the current week in the year
DAY - The number of seconds in a day
WEEK - The number of seconds in a week
MAXDAY - The max day-of-the-week num.
The bulk of the work is performed by the line immediately preceeding the 'return $t;'.
First of all the weekending timestamp is defined for the current week '((MAXDAY - $dx) * DAY)
' it is then adjusted for the week of the year that you wish to determine weekending date for
by the '(($wkno - $woy) * WEEK)' term.
Returns: A timestamp ($t) for the weekending (a Saturday) relating to the week number passed the
date is then generated in the main program using a line like..... '$wkending =
date("d/m/y",(wend($wk)));'
function wend($wkno)
{
define ("DAY", "86400");
define ("WEEK", "604800");
define ("MAXDAY", "6");
$t = time();
$dx = date("w");
$woy = exec('date +%U');
$t += (((MAXDAY - $dx) * DAY) + (($wkno - $woy) * WEEK));
return $t;
}