note 93235 added to function.date

From: Date: Sat, 29 Aug 2009 18:02:42 +0000
Subject: note 93235 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-160033@lists.php.net to get a copy of this message
Easy way to numeric representation of a quarter from passed as parametr date. <?php /** * quarterByDate() * * Return numeric representation of a quarter from passed free-form date. * * @param mixed $date * @return integer */ function quarterByDate($date) { return (int)floor(date('m', strtotime($date)) / 3.1) + 1; } ?> Example: <?php $quarter = quarterByDate(date('Y-m-d')); // current quarter. For 2009-08-29 will be "3" $quarter = quarterByDate('2009-12'); // will be "4" $quarter = quarterByDate('March'); // will be "1" ?> I hope it will be useful. Best regards, S_P_E_C ---- Server IP: 82.177.164.100 Probable Submitter: 93.105.91.40 ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- https://master.php.net/note/edit/93235 Del: integrated -- https://master.php.net/note/delete/93235/integrated Del: useless -- https://master.php.net/note/delete/93235/useless Del: bad code -- https://master.php.net/note/delete/93235/bad+code Del: spam -- https://master.php.net/note/delete/93235/spam Del: non-english -- https://master.php.net/note/delete/93235/non-english Del: in docs -- https://master.php.net/note/delete/93235/in+docs Del: other reasons-- https://master.php.net/note/delete/93235 Reject -- https://master.php.net/note/reject/93235 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#160033) next »