1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.3 Format DateTime

Discussion in 'Styling and Customization Questions' started by Gossamer, Jun 7, 2014.

  1. Gossamer

    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?
     
  2. Amaury

    Amaury Well-Known Member

    Appearance > Languages
     
  3. Gossamer

    Gossamer Active Member

    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.
     
  4. Adam Howard

    Adam Howard Well-Known Member

    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.
     
  5. Gossamer

    Gossamer Active Member

    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.
     
    Adam Howard likes this.

Share This Page