Display custom date format + ordinal suffix

Post

Posted
Rating:
#5194 (In Topic #1174)
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’
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}}
Online now: No Back to the top

Post

Posted
Rating:
#5199
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
Composr provides some extensions such as %o.

Composr Tutorial: Localisation and internationalisation - Composr


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Online now: No Back to the top

Post

Posted
Rating:
#5203
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’
Ah. I was close then! :thumbs:

Code

{$FROM_TIMESTAMP*,%b %e%o %Y\, %l:%M %p,{ADD_DATE_RAW}}
Online now: No Back to the top
1 guest and 0 members have just viewed this.
Back to Top