fancy
fancy

Reputation: 51403

Convert date to elapsed time

Right now I have a date value like so:

2011-04-29T07:08:22.000Z

I want to turn this in to a live updating (no page refresh) elapsed time representation.

What is the most efficient way to do this?

Upvotes: 0

Views: 557

Answers (1)

dwarfy
dwarfy

Reputation: 3076

Use jquery timeago, it's really good and easy.

You just do something like this for initialization :

jQuery(document).ready(function() {
  jQuery("abbr.timeago").timeago();
});

And like this everywhere you want some time to be displayed :

<abbr class="timeago" title="2008-07-17T09:24:17Z">July 17, 2008</abbr>

Upvotes: 2

Related Questions