Customizing SMF > SMF Coding Discussion

Creating Friendly Timestamps

(1/2) > >>

aquagrrl:
Hi all, I'm fairly new to SMF (recent convert from phpbb), but I have to say, so far I really am loving it. I'm working on customizing my theme, and I want the dates to be in a friendlier format. Things like "two days ago" "23 minutes ago". I know a bit of php, so I should be able to make this happen, but I had some questions.

One, before I get crazy making big changes, is there any other way to do this? I see that there was an old mod for the 1.x versions, but nothing new.

If there isn't a mod or setting I'm missing, is there anything I can do with manipulating the time via $board['last_post']['time']? Or some other shortcode/function? (Though, ideally, I want actually two formats, one for a friendly view, and one in the html as a timestamp for the time tag.) I saw timeformat() here, but I didn't see an example of how to use it, so I'm not sure what to do with it.

If I can't use something existing, then the next step is to write a custom function to do it. My question is, where do I do that? I was trying to figure out the best place to write code without changing core features. Is there a place I can put something like this? I could use my own include in the index template, but so far, SMF seems smarter than that. Does it have a good place for this?

Antechinus:
What about this? http://custom.simplemachines.org/mods/index.php?mod=2432

vbgamer45:
timeformat takes a unix time stamp and outputs based on the forums timestamp settings for display.

aquagrrl:
Thank you Antechinus, I didn't see that before, only friendly dates which was for smf 1.x. This will save me a lot of work.

For myself in the future, how would I go about adding a custom function. More specifically, what are the best practices to work with SMF?

Westwegoman:
Since we are on the subject of time here, is there a way to change the time format so that when it shows a post time in the "pm" it shows as "9:55 PM" instead of "09:55 PM"?

When a post time in pm shows with the "0" in front it just doesn't look right.

Navigation

[0] Message Index

[#] Next page

Go to full version