If you pull the full documented source for the rather excellent twitter
widgets (http://twitter.com/widgets), you'll find exactly the routine to do
this.
/**
* relative time calculator
* @param {string} twitter date string returned from Twitter API
* @return {string} relative time like "2 minutes ago"
*/
var timeAgo = function(dateString) {
....
The file has a large comment at the top
* For full documented source see
http://twitter.com/javascripts/widgets/widget.js
* Hosting and modifications of the original source IS allowed.
It also contains gems such as the "Twitalinkahashifyer" - handy routines for
linking "@user" and the like
--
Tim
--
Twitter developer documentation and resources: http://dev.twitter.com/doc
API updates via Twitter: http://twitter.com/twitterapi
Issues/Enhancements Tracker: http://code.google.com/p/twitter-api/issues/list
Change your membership to this group:
http://groups.google.com/group/twitter-development-talk