note 103018 deleted from function.date by tularis

From: Date: Thu, 09 Feb 2012 20:51:38 +0000
Subject: note 103018 deleted from function.date by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-185960@lists.php.net to get a copy of this message
Note Submitter: iantresman ---- 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.

« previous php.notes (#185960) next »