HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


Formatting Date with Tempcode

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#100353 (In Topic #19696)
Avatar

Community saint

How to?

Ok so the tempcode tutorial mentions the {$DATE} tag for formatting but does not give an example how to do so. I wish to change the forum block to format the date like so Sept 16th, 5:30 pm and tried this

Code

{$DATE,'M jS, g:i a',{DATE*}}
but got unexpected results
Back to the top
 
Posted
Rating:
#100354
Avatar

Community saint

Ok so I am almost there with this

Code

{$FROM_TIMESTAMP,M jS  g:i a,{$TO_TIMESTAMP,{DATE*}}}

But I would like a comma

Code

{$FROM_TIMESTAMP,M jS COMMA RIGHT HERE g:i a,{$TO_TIMESTAMP,{DATE*}}}

but don't know how to add it?
Back to the top
 
Posted
Rating:
#100355
Avatar

Community saint

Yeah "This tag takes optional parameters but it is not discussed here" isn't overly helpful lol
Back to the top
 
Posted
Rating:
#100356
Avatar

'DATE' is only the current date, it doesn't support formatting an arbitrary timestamp. We do however have 'FROM_TIMESTAMP', which is based on PHP's strftime (with %k added in to the syntax for the day-of-month-stem, as that is lacking by standard).

Usually we pass in the raw timestamp with a '_RAW' suffix on the parameter name, or a '_' prefix.

So, what you want may be:

{$FROM_TIMESTAMP,%B %e%k\, %l:%M %P,{DATE_RAW}}
or possibly
{$FROM_TIMESTAMP,%B %e%k\, %l:%M %P,{_DATE}}


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
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 ocPortal whenever you see the opportunity.
  • 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 ocPortal 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.
Back to the top
 
Posted
Rating:
#100357
Avatar

Duck said

Yeah "This tag takes optional parameters but it is not discussed here" isn't overly helpful lol

The easiest thing for a programmer is just to look at how sources/symbols.php implements it. It's all really a big switch…case statement in that file.

We just document things up to a point where, any further you'd be at a level where you'd need to know PHP for other things you'd be trying to do at that level. I figure it is better to not overwhelm.
That said, it was not clear that 'DATE' did not take a timestamp, so I'm going to clarify that.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
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 ocPortal whenever you see the opportunity.
  • 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 ocPortal 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.
Back to the top
 
There are too many online users to list.
Control functions:

Quick reply   Contract

Your name:
Your message: