Kirill N Posted March 3, 2015 Posted March 3, 2015 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?
JarredB Posted March 3, 2015 Posted March 3, 2015 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
Kirill N Posted March 3, 2015 Author Posted March 3, 2015 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.
JarredB Posted March 3, 2015 Posted March 3, 2015 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.
Kirill N Posted March 3, 2015 Author Posted March 3, 2015 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.
JarredB Posted March 3, 2015 Posted March 3, 2015 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.
Kirill N Posted March 3, 2015 Author Posted March 3, 2015 Well basically I want to modify the code {datetime="$lastPost['date']"} so that it displays "13 hr" instead of "13 hours ago"
Recommended Posts
Archived
This topic is now archived and is closed to further replies.