For example: 1:49pm Tuesday the 11th Currently, the best approximation would be: %l:%M %A the %d which results in: 1:49pm Tuesday the 11 Sample code: function ordinal($num){ $result = "th"; if($num < 4 && > 20){ switch (substr($num, -1)) { case 1: $result = "st"; break; case 2: $result = "nd"; break; case 3: $result = "rd"; break; } } return $result; }
I forgot am/pm but you get what I'm sayin'.
That's impossible to get right for all languages. I guess you'd have to define custom prefixes and suffixes which translators could then fill in. I don't think this will ever work reliably for all languages though...
Simon, good point about how it would work for other languages. Can we at least get it working for English? I did minimal research on this and it seems like this is mainly an English problem. A few other common languages don't really have ordinals. They just put a period after the number. See this for reference: http://www.typophile.com/node/42577
Sorry but I'm not interested in writing extra code that will only benefit one locale/language (even though it may be one of the most widespread languages). Either it's supported by GDateTime or we won't support it: https://developer.gnome.org/glib/stable/glib-GDateTime.html#g-date-time-format