Instead of thinking about time in absolute numbers, we often think relative. Like “I bought a new pair of shoes yesterday”, “My car's windshield broke this morning” (sad but true) or “I will start dieting. Tomorrow.”
Time is easier to grab this way, that's why you often find such relative time hints in various blogs and online publications also. Instead of showing an absolute date, vBulletin for example writes “Yesterday, 6.00am”. Google Desktop shows hints like “9 min ago” for its RSS feeds (Web Clips).
This approach of showing up intervals instead of absolute numbers makes it easier to comprehend time and date, not only for me. So I wanted to have that on my phpWebSite, too. This time, I didn't just hack one particular module. No, I wrote a new function for core/TimeDate.php
, so this way of showing time-spans would be available all over phpWebSite.
To use the new function “relativeTime()” in a module not listed in the mentioned thread, please:
1) do a “require_once(PHPWS_SOURCE_DIR . 'core/DateTime.php');”
2) do a “PHPWS_DateTime::relativeTime($timestamp);” where you'd like to have the relative timestamp.
I've shown how to do it for Article Manager and phpWSBB, you should be able to convert this technique to any other module you like to.
Where to get it?
You can get the technical details in this thread. Please feel free to reply in that thread regarding how to implement that in other modules or general questions / comments.