note 88248 modified in control-structures.switch by felipe

From: Date: Sat, 17 Jan 2009 00:43:33 +0000
Subject: note 88248 modified in control-structures.switch by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-149346@lists.php.net to get a copy of this message
This is what I did while deciphering what quarter a date (string) belonged to... <?php $strdate = 'Jun 4 2008 11:34PM'; $month = date('M', strtotime($strdate)); switch ($month) { case ($month=='Jan' || $month=='Feb' || $month=='Mar'): $quarter = "Q1 2008"; break; case ($month=='Apr' || $month=='May' || $month=='Jun'): $quarter = "Q2 2008"; break; case ($month=='Jul' || $month=='Aug' || $month=='Sep'): $quarter = "Q3 2008"; break; case ($month=='Oct' || $month=='Nov' || $month=='Dec'): $quarter = "Q4 2008"; break; } ?> --was-- This is what I did while deciphering what quarter a date (string) belonged to... [PHP] $strdate = 'Jun 4 2008 11:34PM'; $month = date('M', strtotime($strdate)); switch ($month) { case ($month=='Jan' || $month=='Feb' || $month=='Mar'): $quarter = "Q1 2008"; break; case ($month=='Apr' || $month=='May' || $month=='Jun'): $quarter = "Q2 2008"; break; case ($month=='Jul' || $month=='Aug' || $month=='Sep'): $quarter = "Q3 2008"; break; case ($month=='Oct' || $month=='Nov' || $month=='Dec'): $quarter = "Q4 2008"; break; } [/PHP] http://php.net/manual/en/control-structures.switch.php

« previous php.notes (#149346) next »