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

XF 1.4 Show only month and year for date joined

Discussion in 'XenForo Questions and Support' started by JackieChun, Jun 30, 2015.

  1. JackieChun

    JackieChun Active Member

    How can I edit $user.register_date to show month and year only? I only want this change enabled in the postbit, so I'm only editing one template.
     
  2. Valhalla

    Valhalla Well-Known Member

    {xen:date $user.register_date, 'M Y'}
     
    JackieChun likes this.
  3. JackieChun

    JackieChun Active Member

    Thank you so much!
     
  4. JackieChun

    JackieChun Active Member

    Ah, but that kills the feature that shows the date as "Friday" etc, if the member joined less than a few days ago. Any way to keep both features?
     
  5. Valhalla

    Valhalla Well-Known Member

    You could use this, in place of what I posted above:

    Code:
    {xen:if '{$user.register_date} < {xen:calc '{$serverTime} - 86400 * 7'}', '{xen:date $user.register_date, 'M Y'}', '{xen:date $user.register_date}'}
     
    Skylined and JackieChun like this.
  6. JackieChun

    JackieChun Active Member

    Thanks. I might leave your earlier version. This seems like an unnecessary extra query, and I don't want to overload the server.
     
  7. Brogan

    Brogan XenForo Moderator Staff Member

    There is no additional query involved in that code - the data is already exposed to the template, it is just being manipulated based on a condition.
     
    JackieChun likes this.
  8. JackieChun

    JackieChun Active Member

    The new version of the code seems to be working great. Thank you guys!
     

Share This Page