XF 1.3 Format DateTime

Gossamer

Active member
Hello! I'm pulling a timestamp into a template using:
Code:
<xen:datetime time="$ExistingReserve.expiration" />

That makes it output as: Jun 14, 2014 at 5:48 PM

I'd like for it to output as 6/14/14. How can I go about formatting it this way?
 
Yep, I know I can change the format there for the entire forum.

However, I just want it to display in a specific manner on this one template in an add-on I'm creating.
 
Yep, I know I can change the format there for the entire forum.

However, I just want it to display in a specific manner on this one template in an add-on I'm creating.
I'm fairly sure you can't limit this to a single template. The template system plugs into the hook setting that you have configured in your language format.

With that said, I'm sure someone could make an add-on to plug into that hook.
 
Oh, found it!

Code:
{xen:date $reserve.expiration, 'M d'}
Outputs: Jun 14

There's a list of usable format variables I found in XenForo_Locale::getFormattedDateInternal. Not sure if they're supposed to work with xen:datetime too, cause I had a lot of trouble finding a combination that did work. But glad to see it was possible.
 
Top Bottom