note 41718 added to function.date

From: Date: Tue, 20 Apr 2004 23:09:40 +0000
Subject: note 41718 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-68392@lists.php.net to get a copy of this message
If you would like the numerical representation of the day of the week to start counting from Monday (thus, Monday = 0) -- which would be more logical -- instead of Sunday (Sunday = 0), then you could use something like the following code. $weekday = (date("w") + 6) % 7; Does it work? Yes, it does: On Mondays, date("w") yields 1, resulting in (1 + 6) % 7 = 0. On Tuesdays, date("w") yields 2, resulting in (2 + 6) % 7 = 1. ... On Saturdays, date("w") yields 6, resulting in (6 + 6) % 7 = 5. On Sundays, date("w") yields 0, resulting in (0 + 6) % 7 = 6. ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+41718 Delete -- http://master.php.net/manage/user-notes.php?action=delete+41718&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+41718&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#68392) next »