Adding tooltip to post time

Started by confuseamuse, August 01, 2017, 10:30:13 AM

Previous topic - Next topic

confuseamuse

In conjunction with a mod that turns the post time relative (example "about an hour ago" instead of "01/08/17 14:26:16 BST"), I'd like to add an edit to the post time which displays a tooltip with a more accurate post time (as seen above).

That way, you get the best of both. I'm having trouble coding it though.

So far, I've managed to get the tooltip to display the time, but it displays the current time only, instead of just the post time. So it looks like this:


Note: The forum time is offset by UTC+1 in the post whilst the tooltip runs off the current time (as of the screenshot) in UTC.

Here's the code I have in Display.template
<div class="smalltext"><a href="', $message['href'], '" rel="nofollow" title="', timeformat(time(),'%a %e %b %Y - %T' , $message['time']), '">

Any ideas?

Shambles

Try

Code (find) Select
<div class="smalltext"><a href="', $message['href'], '" rel="nofollow" title="', timeformat(time(),'%a %e %b %Y - %T' , $message['time']), '">

Code (replace with) Select
<div class="smalltext"><a href="', $message['href'], '" rel="nofollow" title="', timeformat(strtotime($message['time']),'%a %e %b %Y - %T'), '">

I think that's what you may be after.

confuseamuse

Quote from: Shambles on August 01, 2017, 11:02:10 AM
Try

Code (find) Select
<div class="smalltext"><a href="', $message['href'], '" rel="nofollow" title="', timeformat(time(),'%a %e %b %Y - %T' , $message['time']), '">

Code (replace with) Select
<div class="smalltext"><a href="', $message['href'], '" rel="nofollow" title="', timeformat(strtotime($message['time']),'%a %e %b %Y - %T'), '">

I think that's what you may be after.

This almost worked. Now the tooltip prints the time relative to the mod statement. (e.g. If a post says (posted 3 hours ago) it prints the time exactly three hour prior from now.) I think the mod actively changes the posted time, which is slightly annoying. Can this be changed to print the timestamp directly from the database instead?

Shambles

If you believe it's an issue with the mod you need to ask in the mod's support thread.

That said, try the following to see if it fits your requirement:

<div class="smalltext"><a href="', $message['href'], '" rel="nofollow" title="', timeformat(strtotime($message['time']),'%a %e %b %Y - %T','forum'), '">

Advertisement: