[solved] CGCalendar: 3-letter month names

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
Cerulean
Forum Members
Forum Members
Posts: 172
Joined: Mon Nov 01, 2010 8:56 am

[solved] CGCalendar: 3-letter month names

Post by Cerulean »

I'm working on my first project using CGCalendar.

Looking at one of the sample templates I see...

Code: Select all

{assign var=month_number value=$event.event_date_start|date_format:"%m"}
{$month_names[$month_number]}
If I want my event start date formatted with 3-letter months (Jan, Feb, etc), do I have to create my own Smarty array of custom month names and get the name from the array using the month number?

Not a problem if so, just wanting to check that there's not an easier way using date_format or something...
Last edited by Cerulean on Wed May 14, 2014 7:42 am, edited 1 time in total.
Cerulean
Forum Members
Forum Members
Posts: 172
Joined: Mon Nov 01, 2010 8:56 am

Re: CGCalendar: 3-letter month names

Post by Cerulean »

I guess I can just do...

Code: Select all

{$month_names[$month_number]|truncate:3:""}
I thought that maybe the event start date would be passed as a time stamp that could be formatted to a 3-letter month, but it looks like the Smarty date_format modifier doesn't include a short month format: http://www.smarty.net/docs/en/language. ... format.tpl
It seems "%M" is "minute as a decimal number", which is strange because in the PHP date_format function "M" is "A short textual representation of a month (three letters)".
User avatar
Jo Morg
Dev Team Member
Dev Team Member
Posts: 1978
Joined: Mon Jan 29, 2007 4:47 pm

Re: CGCalendar: 3-letter month names

Post by Jo Morg »

%b - abbreviated month name according to the current locale
In PHP as in Smarty... Check also cms_date_format modifier.

ps: note that this comes from the standard strftime parameters, not the PHP date_format function.
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
Cerulean
Forum Members
Forum Members
Posts: 172
Joined: Mon Nov 01, 2010 8:56 am

Re: CGCalendar: 3-letter month names

Post by Cerulean »

Right you are, thanks.

{$event.event_date_start|date_format:"%b"} gives a 3-letter month.

Confusing how the PHP strftime and date_format functions use some of the same character codes but for different date formats.
Post Reply

Return to “Modules/Add-Ons”