/Humane-Dates

Show the difference between a date and now (4 days ago)

Primary LanguageJavaScript

A better way to display relative dates using JavaScript. Instead of a raw date
string, this script will return strings like "2 hours ago" or "5 days".


For internationalization, include a "lang/XX.js" file just before humane.js:
  <script src="lang/sv.js" type="text/javascript"></script>
  <script src="humane.js" type="text/javascript"></script>


JavaScript Usage: (returns string)

  humaneDate(new Date);
  humaneDate('2008-01-28 20:24:17');


jQuery Plugin Usage:

  <span title="2008-01-28 20:24:17">January 1, 2008 20:24:17 GMT</span>

  $('span').humaneDates();

  <time datetime="2008-01-28 20:24:17">January 1, 2008 20:24:17 GMT</time>

  $('time').humaneDates();


Copyright (c) 2008 Dean Landolt (deanlandolt.com)
Re-write by Zach Leatherman (zachleat.com)
Re-write by Magnus Johansson (mfjohansson.nu)
 
Adopted from the John Resig's pretty.js
    at http://ejohn.org/blog/javascript-pretty-date
and henrah's proposed modification 
    at http://ejohn.org/blog/javascript-pretty-date/#comment-297458

Licensed under the MIT license.