Display custom date format + ordinal suffix

Post

Posted
Rating:
#4855 (In Topic #980)
Joe
I'm trying to find an easier alternative to displaying this date format from a timestamp: Oct 27th 2018, 10:00 AM (includes ordinal suffix).

I've only been able to achieve showing the ordinal suffix by adding a new symbol that does this automatically ({$ORDINAL}) but I have to split up the date in multiple {$FROM_TIMESTAMP} symbols to use this method. Frankly, it looks kinda hideous:

Code

{$FROM_TIMESTAMP*,%b,{ADD_DATE_RAW}} {$ORDINAL,{$FROM_TIMESTAMP*,%e,{ADD_DATE_RAW}}} {$FROM_TIMESTAMP*,%Y\, %l:%M %p,{ADD_DATE_RAW}}

The above works, but I was hoping for a much simpler way of doing this. According to a user comment on php.net, we can use a %O (capital 'o') parameter to display the ordinal suffix (though it's not officially documented as supported using php's strftime).

I tried this but it doesn't work:

Code

{$FROM_TIMESTAMP*,%b %e %O %Y\, %l:%M %p,{ADD_DATE_RAW}}

Post

Posted
Rating:
#4860
Composr provides some extensions such as %o.

Composr Tutorial: Localisation and internationalisation

Open Source CMS with advanced social, interactive and dynamic features. Fully flexible, themeable and extendible: suitable for building powerful websites.

View


Post

Posted
Rating:
#4864
Joe
Ah. I was close then! :thumbs:

Code

{$FROM_TIMESTAMP*,%b %e%o %Y\, %l:%M %p,{ADD_DATE_RAW}}
0 guests and 0 members have recently viewed this.