note 103018 added to function.date

From: Date: Sun, 20 Mar 2011 23:49:24 +0000
Subject: note 103018 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-178033@lists.php.net to get a copy of this message
Here's a quick way to display the season (Winter, Spring, Summer, Autumn) from a date. Dec, Jan, Feb are Winter, etc. <?php $seasons = array("Winter","Spring","Summer","Autumn"); echo $seasons[(int)((date("n") %12)/3)]; ?> date("n") produces a numeric month 1..12 date("n") %12 (modulus 12) converts month 12 (Dec) to 0 Then we divide by 3 and convert to an integer to produce four groups, 0,1,2,3. Then we display the nth array element. ---- Server IP: 87.124.126.137 Probable Submitter: 93.97.21.214 (proxied: 93.97.21.214) ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- https://master.php.net/note/edit/103018 Del: integrated -- https://master.php.net/note/delete/103018/integrated Del: useless -- https://master.php.net/note/delete/103018/useless Del: bad code -- https://master.php.net/note/delete/103018/bad+code Del: spam -- https://master.php.net/note/delete/103018/spam Del: non-english -- https://master.php.net/note/delete/103018/non-english Del: in docs -- https://master.php.net/note/delete/103018/in+docs Del: other reasons-- https://master.php.net/note/delete/103018 Reject -- https://master.php.net/note/reject/103018 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#178033) next »