[PHP-users 2261] Re: 1 -> 1st, 2 -> 2nd ...
Nakagawa, Yasuharu
php-users@php.gr.jp
Wed, 26 Sep 2001 14:54:15 +0900
中川@東京武蔵野です。
0---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
もっとひねってこれでは?
function ordinal($a){
$a = (int)$a;
return ($a<20)?date("jS", mktime(0,0,0,1,$a,2001)):$a.'th';
}
In message Sub:[PHP-users 2260] Re: 1 -> 1st, 2 -> 2nd ... on 2001/09/26;
<B7D79976.134A7%shige@ravi.ne.jp>,
Osamu Shigematsu wrote...
>重松です。こんにちは。
>
>>> date() とかじゃダメですか?
>> $day = date("F jS", mktime(0,0,0,10,1,2001));
>
>
> function ordinal($a){
> $a = (int)$a;
> if((($a / 10) % 10) == 1) return $a . 'th';
> switch($a % 10){
> case 1: return $a . 'st';
> case 2: return $a . 'nd';
> case 3: return $a . 'rd';
> }
> return $a . 'th';
> }
>