• 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

Andy.N

Well-known member
#1
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
 

Jeremy

Well-known member
#2
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.
 

Andy.N

Well-known member
#3
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.
Here is the pice that shows it
{xen:datetime {$post.post_date}}

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

Jeremy

Well-known member
#7
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

Well-known member
#10
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...
Ah, you gave me the good pointer to get on it. Thanks Mike.