I feel a bit silly for this one, but is there a more elegant way to format the day number suffix (st, th) other than by having to call the date() 3 times?
What I am trying to output in html:
<p>January, 1<sup>st</sup>, 2011</p>
What I am doing now (feels very heavy) in php:
//I am omitting the <p> tags:
echo date('M j',$timestamp)
. '<sup>' . date('S', $timestamp) . '</sup>'
. date(' Y', $timestamp);
Anyone knows a better way?
You just have to escape characters that are interpreted by the date function.
At PHP date documentation you have a list with all characters replaced by their special meaning.