note 58443 added to function.date

From: Date: Fri, 04 Nov 2005 12:04:05 +0000
Subject: note 58443 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-98066@lists.php.net to get a copy of this message
If you want to find the corresponding starting and ending dates for a given week of a year: function findWeekPeriod($week, $year) { $aPeriod = array(); // if you are a Catholic you should use $x = 0 considering Sunday as the first day of the week. I'm an Orthodox so I consider it the seventh day of the week $x = 1; $aPeriod['start'] = date("Y-m-d H:i:s", mktime(0, 0, 0, 1, 1 + $week*7 + $x - 6, $year)); $aPeriod['end'] = date("Y-m-d H:i:s", mktime(0, 0, 0, 1, 1 + $week*7 + $x, $year)); return $aPeriod; } For week 44 of the year 2005 (as an example), you will get: Array ( [start] => 2005-10-31 00:00:00 [end] => 2005-11-06 00:00:00 ) ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+58443 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58443&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58443&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58443&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58443&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58443&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58443&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58443&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+58443&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#98066) next »