note 92547 added to function.date
| From: | crayonviolent at phpfreaks dot com | Date: | Wed, 29 Jul 2009 00:25:30 +0000 |
| Subject: | note 92547 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-158850@lists.php.net to get a copy of this message | ||
Haven't really tested it performance-wise vs. other methods, but I thought I'd post this
anyways...
Here's a nifty way to exploit date()'s built-in ordinal suffix calculator to append the
proper ordinal suffix to an arbitrary number:
function addOrdinal($num=0){
return $num.(((strlen($num)>1)&&(substr($num,-2,1)=='1'))?
'th' : date("S",mktime(0,0,0,0,substr($num,-1),0)));
} // end function addOrdinal
----
Server IP: 64.71.164.2
Probable Submitter: 96.35.231.166
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- https://master.php.net/note/edit/92547
Del: integrated -- https://master.php.net/note/delete/92547/integrated
Del: useless -- https://master.php.net/note/delete/92547/useless
Del: bad code -- https://master.php.net/note/delete/92547/bad+code
Del: spam -- https://master.php.net/note/delete/92547/spam
Del: non-english -- https://master.php.net/note/delete/92547/non-english
Del: in docs -- https://master.php.net/note/delete/92547/in+docs
Del: other reasons-- https://master.php.net/note/delete/92547
Reject -- https://master.php.net/note/reject/92547
Search -- https://master.php.net/manage/user-notes.php