note 45517 deleted from function.date by tomsommer
| From: | tomsommer@php.net | Date: | Thu, 09 Sep 2004 20:25:35 +0000 |
| Subject: | note 45517 deleted from function.date by tomsommer | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-76350@lists.php.net to get a copy of this message | ||
Note Submitter: michael at michaelthompson dot org
----
The 'S' doesn't work the way you might expect to... for example, on the 251st day of
the year date("zS") returns "251th" instead of "251st" Here is an
nTh() function I use to achieve the desired effect.
function nTh( $n )
{
if( $n>4 && $n<21 ) $rtn = "th";
else
{
$it = substr($n,strlen($n)-1,1);
switch( $it )
{
default:
$rtn = "th";
break;
case 1:
$rtn = "st";
break;
case 2:
$rtn = "nd";
break;
case 3:
$rtn = "rd";
break;
}
}
return $rtn;
}