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

XF 1.2 Time display format

Discussion in 'XenForo Questions and Support' started by Andy.N, Aug 15, 2013.

  1. Andy.N

    Andy.N Well-Known Member

    I'd like to display the time in a format that is a bit controllable. Right now, I have an addon where the time is displayed relatively.
    So I have

    3 minutes ago
    Today at 4:15 AM
    Yesterday at 2:39 PM
    Monday at 1:23 PM

    As you can see, it's hard to control the width of the column for this output as it varies greatly.
    Is there a different format that I can apply to this addon only so that they can be more consistent.

    Thank you
  2. Jeremy

    Jeremy XenForo Moderator Staff Member

    Try removing the "DateTime" class from the HTML (you may need to stop using <xen:datetime /> to accomplish this). It should remove the JavaScript binding that works to make them relative.
  3. Andy.N

    Andy.N Well-Known Member

    Here is the pice that shows it
    {xen:datetime {$post.post_date}}

    if I remove xen:datetime, it will display in unix date 12324312312
  4. Jeremy

    Jeremy XenForo Moderator Staff Member

    {xen:datetime {$post.post_date}, absolute}
  5. Andy.N

    Andy.N Well-Known Member

    Everything shows as
    Aug 15, 2013 at 11:01 AM which is much longer. Is there some way to format it as
    8/15 at 11:01 AM
  6. Brogan

    Brogan XenForo Moderator Staff Member

    Click on the language and change the format there.

    That is a global setting though.
    Andy.N likes this.
  7. Jeremy

    Jeremy XenForo Moderator Staff Member

    You will either have to write your own helper to format it individually here, or globally change the date format; it runs off of the language settings.
    Andy.N likes this.
  8. Andy.N

    Andy.N Well-Known Member

    Thank you both. Is it possible to use the 24 hour time format?
  9. Mike

    Mike XenForo Developer Staff Member

    You can use {xen:date $x, 'format'} and/or {xen:time $x, 'format'} with the "format" value being a PHP date()-style formatter to output a specific format.

    This is getting very advanced now though...
  10. Andy.N

    Andy.N Well-Known Member

    Ah, you gave me the good pointer to get on it. Thanks Mike.
  11. ReneHermi

    ReneHermi Member

    Guys, @Brogan already told it;) It´s much more easier and fully controlable via acp

    Attached Files:

    radu81 likes this.
  12. Jeremy

    Jeremy XenForo Moderator Staff Member

    That changes it globally, this thread was about changing the format in a single instance.
    ReneHermi likes this.

Share This Page