Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Suffix in a day (1st, 2nd...)

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks
View previous topic :: View next topic  
Author Message
bimal
Smarty Elite


Joined: 19 Apr 2007
Posts: 423

PostPosted: Thu Jul 02, 2009 6:22 pm    Post subject: Suffix in a day (1st, 2nd...) Reply with quote

date_format in Smarty is not enough to print out the suffix of the days.
For example, I wanted to print out
Code:
Friday, 03rd July, 2009

, but it is not possible with:
Code:
{$smarty.now|date_format:'%A, %e %B, %Y'}

. Hence, I decided to go with php's callable date:
Code:
{'l, dS F, Y'|date}


Is this a nice trick over Smarty's default distribution? Laughing
If you would like to help me, please let me know, how to remove 0 in the days where, the day is less than 10. For example, it gives 01st, but I want 1st.
Back to top
View user's profile Send private message Visit poster's website
jLix
Smarty Regular


Joined: 01 Apr 2009
Posts: 59
Location: Lowlands, EU

PostPosted: Fri Jul 03, 2009 2:33 am    Post subject: Re: Suffix in a day (1st, 2nd...) Reply with quote

bimal wrote:
If you would like to help me, please let me know, how to remove 0 in the days where, the day is less than 10. For example, it gives 01st, but I want 1st.

Code:
{'l, jS F, Y'|date}
instead of
Code:
{'l, dS F, Y'|date}

_________________
http://jlix.net/extensions/smarty
Back to top
View user's profile Send private message Visit poster's website
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Feb 04, 2010 11:03 pm    Post subject: Reply with quote

FYI, Smarty 3 date_format modifier now accepts php date() style formatters.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP