I guess most of us believe that not all users are robots, and especially in social applications where you try to approach humans as human friendly as possible the display of date and time in such format can be off added value.
There are many scripts to display date and time in a human friendly format. For a project we are using timeago, a jQuery plugin that makes it easy to support automatically updating fuzzy timestamps (e.g. “4 minutes ago” or “about 1 day ago”).
However, in combination with an infinite scroll feature to navigate through document collections we notice that the script not always return instantly the transformed date/time.
That is why I looked at a server-side transformation.
PrettyTime is an OpenSource time formatting library. Completely customizable, it creates human readable, relative timestamps like those seen on Digg, Twitter, and Facebook.
It turned out the implementation of PrettyTime was quiet simple. I will describe the steps for you.
Install the jar & call the Java class
p = new org.ocpsoft.pretty.time.PrettyTime();
As a result I get to date displayed as:
Pro’s & Con’s
In comparison with client-side solutions I have detect some con’s and pro’s for a server side solution:
- Static; the client side solutions are capably of updating the date/time value on the fly.
- Speed; the server side generated human friendly date is there when a document row is presented.
- Extensibility; the number of display languages is more numerous for most client-side solutions. Also you can often “configure” the text format when desired.
- Consistency; having a human friendly date in a local language may be in conflict with internationalization of your XPages app since that might require more work.
Anyway: I happy to hear how you have solved the human friendly date issue.