note 92547 deleted from function.date by tularis
| From: | tularis@php.net | Date: | Thu, 09 Feb 2012 20:56:28 +0000 |
| Subject: | note 92547 deleted from function.date by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-185985@lists.php.net to get a copy of this message | ||
Note Submitter: crayonviolent at phpfreaks dot com
----
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:
<?php
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
?>