tags:

views:

50

answers:

3

I want to express the date in PHP as "May Fourteenth Two-thousand and ten", any ideas? Extra but not necessary would be the time like "Eight forty-eight PM"?

A: 

I would start with some switch statements and some if/elseif statements. That should be good.

switch(date('n'))
{
case "1":echo "First";break;
...
case "14":echo "Fourteenth";break;
...
}
webdestroya
+1  A: 

I solved a small part of this problem, in Perl: http://dj-skittles.dreamwidth.org/4107.html

It gives source for converting 1 => first, 2=> second, 3 => third all the way through 99.

amphetamachine
+2  A: 

A quick Google search led to this: PHP number => word converter

You can use something like that and translate each part of the date to a word.

num2word(date('d'))

assuming that you adapted the function I linked to your specific needs (you may not want it to be able to spell out "nonillion" as it currently does, but you want the numbers to be both ordinals and cardinals) and called it num2word(), it will give you the current day in word (today is the 15th, so fifteenth, same with date('Y') which would lead to two thousand and ten, and so on).

Note that the function I found may not be the best one around (it's just the first result), try searching for "php word number"

MartinodF