note 68852 added to function.date

From: Date: Sun, 13 Aug 2006 11:07:01 +0000
Subject: note 68852 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-115855@lists.php.net to get a copy of this message
To make a graphical layout of a calendar, running Monday to Sunday, you first need to make some blank days, if the month isn’t starting on a Monday. To find this number of blank days, you can very simple just -1 from the date(w, $first_day_of_the_month) function to change it from a Sunday-Saturday to Monday-Sunday format... But there’s a little tricky problem, if the first day of the month is a Sunday (native day 0 of the month), the var is a value of -1, which could be a problem... (In my calendar anyway) But a little if statement fixes this, very well: if ($dayone < 0){ $dayone = $dayone + 7; } By adding 7 to -1 you get the six blank days, as you should :-) Know this isn’t rocket science, but I didn’t spot this problem my self, until my boss called me up, and complained that October 1 wasn’t a Monday... Hope this could help with similar problems! ---- Server IP: 194.239.128.50 Probable Submitter: 84.238.93.234 ---- X-Spam-Status: Yes, hits=7.4 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER, HEAD_ILLEGAL_CHARS autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- https://master.php.net/note/edit/68852 Del: integrated -- https://master.php.net/note/delete/68852/integrated Del: useless -- https://master.php.net/note/delete/68852/useless Del: bad code -- https://master.php.net/note/delete/68852/bad+code Del: spam -- https://master.php.net/note/delete/68852/spam Del: non-english -- https://master.php.net/note/delete/68852/non-english Del: in docs -- https://master.php.net/note/delete/68852/in+docs Del: other reasons-- https://master.php.net/note/delete/68852 Reject -- https://master.php.net/note/reject/68852 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#115855) next »