note 22978 added to function.getdate
| From: | mike_r_goetz at hotmail dot com | Date: | Fri, 05 Jul 2002 20:44:51 +0000 |
| Subject: | note 22978 added to function.getdate | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-32647@lists.php.net to get a copy of this message | ||
Two related date issues regarding the 'week of year' and 'week of month'.
Firstly, use this function to get the week of the year if your week starts on a Sunday:
function week_of_year($day, $month, $year) {
$timestamp = mktime(0,0,0,$month,$day,$year);
$date = getdate($timestamp);
$woy = date('W', $timestamp);
if ($date['wday'] == 0) {
$woy++;
}
return $woy;
}
Secondly, use the following function (based on the one above) to get the week of the month (eg. Jul
7, 2002 is in the 2nd week of July):
function week_of_month($day, $month, $year) {
return (week_of_year($day, $month, $year) - week_of_year(1,$month,$year) + 1);
}
--
http://www.php.net/manual/en/function.getdate.php
http://master.php.net/manage/user-notes.php?action=edit+22978
http://master.php.net/manage/user-notes.php?action=delete+22978
http://master.php.net/manage/user-notes.php?action=reject+22978