MovableBlog: Ordinal Numbers with MT and PHP
December 7, 2002
A subtle change to the date headers here at MovableBLOG. There are now "st" after any date with the day of the month being 1 or 21, "nd" after the days of the month 2 and 22, "rd" after days of the month 3 and 23, as well as "th" for any other day of the month. I didn't find a solution in the MT manual, but it apppears there is a plugin which can convert dates in to ordinal numbers.
It probably would have done me some good to look in the MT forums, since a solution was already posted by billzeller. But since I took the time to code it myself, I might as well publish it:
$dateToday = <$MTEntryDate format="%e"$>;
$dayEnding = "st";
$dayEnding = "nd";
$dayEnding = "rd";
$dayEnding = "th";
print "<$MTEntryDate format="%B %e"$>".$dayEnding.", <$MTEntryDate format="%Y"$>";
Play around with that last print statement to get the desired date format.