Jump to content

Template help: How to display short date?


Kirill N

Recommended Posts

Posted

On mobile, you can see that some dates are displayed as "2 min" instead "2 minutes" or "1 hr" instead of "1 hour". What's the code to display the time in this format?

Posted

Hi Kirill,

This is done through HTML. Take for example this piece of markup:

<time datetime="2015-03-02T18:49:17Z" title="03/03/2015  4:49  AM" data-short="13 hr">13 hours ago</time>

You can see the part "data-short". This is the short version.

To generate this markup based on your chosen time, there is a template tag for this, e.g

{date="699753360"}

For more information see Dates & Times here: https://invisionpower.com/4guides/themes-and-customizations/template-syntax/template-plugins-r143/Hope that helps :)

 

Posted

Hi @BlistDev,

Thanks for your response.

I'm a bit confused because what I'm trying to do is replace the template tag:

{datetime="$lastPost['date']"}

with one that would display the short version. 

I tried adding the template tag you provided but it didn't work.

Posted

    I'm a bit confused because what I'm trying to do is replace the template tag:

{datetime="$lastPost['date']"}

with one that would display the short version. 

I tried adding the template tag you provided but it didn't work.

​Hmmm, where are you using it? Does the "data-short" attribute appear in the HTML where you have used the tag?

The code you have quoted is also used on the forum index which does show a short version. According to the docs it is meant to generate a shortened version, but I have not tested this myself yet.

Posted

​Hmmm, where are you using it? Does the "data-short" attribute appear in the HTML where you have used the tag?

The code you have quoted is also used on the forum index which does show a short version. According to the docs it is meant to generate a shortened version, but I have not tested this myself yet.

​I am indeed using it on the forum index to display the date of the last post. On desktop it shows the full format "12 hours ago", but on mobile it shrinks to "12 hrs". What I want is for it to always show "12 hours", on both desktop and mobile.

Posted

​I am indeed using it on the forum index to display the date of the last post. On desktop it shows the full format "12 hours ago", but on mobile it shrinks to "12 hrs". What I want is for it to always show "12 hours", on both desktop and mobile.

​My apologies, I read your question the other way around thinking you were trying to make a date appear short because it wasn't.

The "norelative" option doesn't appear to be working for me. Ryan looks like he might be replying to this, so he may have the solution for you.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...