note 9820 added to Date and Time functions

From: Date: Sun, 26 Nov 2000 15:38:52 +0000
Subject: note 9820 added to Date and Time functions
Groups: php.notes 
Request: Send a blank email to php-notes+get-8146@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; } http://www.php.net/manual/ref.datetime.php

« previous php.notes (#8146) next »