Pretty Dates in JavaScript

A common way of expressing dates nowadays is to represent them as an approximate age.

For example, rather than saying something happened at 5/5/2008 4:21:01 PM, we can say it happened one minute ago.

I wanted to use this in DovetailAgent to show the age of the Search indexes. A little Googling brought me to John Resig’s implementation of prettyDate() in JavaScript.

I tried it out, it was OK.

Looking through the comments on John’s post, I saw that Dean Landolt posted an updated function that I liked better.

I tried it, but it still had a few issues.

Finally, Zach Letterman commented that he updated Dean’s script, and posted a newer version.

Success! Exactly what I was looking for.

Now when I see my search results, I can also see how current my search data is, in an easy to consume format, without having to do any date arithmetic in my head:


Other uses?

I’m wondering if this would also be useful when displaying dates in other places in Dovetail applications, such as the case history. Do you care that John logged a note at 5/2/2008 1:20:01 PM, or do you care that it happened 3 days ago? Perhaps the activity log still shows the exact date/time, so that data can be easily retrieved, if needed.

Your thoughts?