Is it possible to know the difference between an entry's timestamp and the current time?
I'm working on a template that I would like to show the number of hours (and/or minutes) elapsed since the timestamp if the elapsed time is under a predetermined value (ie, perhaps less than 24 hours old)... and if greater than that value, show the timestamp as usual.
Ideas?
Smarty - elapsed time since posted for an entry?
-
Don Chambers
- Regular
- Posts: 3657
- Joined: Mon Feb 13, 2006 2:40 am
- Location: Chicago, IL, USA
- Contact:
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Smarty - elapsed time since posted for an entry?
Hi!
Yes, $smarty.now contains the current timestamp. Using {math} you can evaluate the difference between that and your entry's timestamp.
Regards,
Garvin
Yes, $smarty.now contains the current timestamp. Using {math} you can evaluate the difference between that and your entry's timestamp.
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
It looks like you want human-readable date/time stamps. (Now I feel like that retarded paper clip!) Smarty doesn't actually include that function, but people have written modifiers to do the job.
Here's a Smarty forum post with two friendly time stamps.
This can go in your template's config.inc.php, as you already know.
Here's a Smarty forum post with two friendly time stamps.
This can go in your template's config.inc.php, as you already know.
-
Don Chambers
- Regular
- Posts: 3657
- Joined: Mon Feb 13, 2006 2:40 am
- Location: Chicago, IL, USA
- Contact: