note 41718 deleted from function.date by kennyt

From: Date: Sun, 18 Jul 2004 17:22:07 +0000
Subject: note 41718 deleted from function.date by kennyt
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-73502@lists.php.net to get a copy of this message
Note Submitter: ln.emoh@mbt (from right to left...) ---- 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.

« previous php.notes (#73502) next »