note 61266 added to function.date

From: Date: Sun, 29 Jan 2006 22:10:54 +0000
Subject: note 61266 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-102689@lists.php.net to get a copy of this message
A correction of "get_week_boundaries". In some countrys, the week is beginning with monday and ending with sunday. function get_week_boundaries($int_time) { // first: find monday 0:00 $weekdayid=date("w",$int_time); // sunday must have w=7, not 0. otherwise sunday will count to the next week * if ($weekdayid == 0) $weekdayid = 7; $dayid=date("j",$int_time); $monthid=date("n", $int_time); $yearid=date("Y", $int_time); $beginofday=mktime(0,0,0,$monthid,$dayid,$yearid); $beginofweek=$beginofday - (($weekdayid-1) * 86400); //86400 == seconds of one day (24 hours) //now add the value of one week and call it the end of the week //NOTE: End of week is Sunday, 23:59:59. I think you could also use Monday 00:00:00 but I though that'd suck $endofweek=($beginofweek + 7 * 86400)-1; $week["begin"]=$beginofweek; $week["end"]=$endofweek; $week["pov"]=$int_time; return $week; } The modification is marked with a *. ---- Server IP: 64.246.30.37 Probable Submitter: 84.173.210.14 ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+61266 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+61266&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+61266&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+61266&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+61266&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+61266&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+61266&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+61266&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+61266&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#102689) next »