Ads

Sunday 27 July 2014

jQuery Age - tracks dates and times as human readable text

Download   Demo


Age is a jQuery plugin that formats and tracks dates and times as human readable text.


1. INCLUDE JS FILES


<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js" type="text/javascript"></script>
<script src="javascript/jquery.age.js" type="text/javascript"></script>

2. HTML


<time datetime="2010-01-01T12:00:00Z" class="age">January 1, 2010 12:00</time>
<time datetime="2020-01-01T12:00:00Z" class="age">January 1, 2020 12:00</time>

3. JAVASCRIPT


$('.age').age();

4. OPTIONS


Age supports a number of configuration settings for customizing the language and intervals:


$('.age').age(
interval: 10000,
suffixes:
past: "ago",
future: "until",
,
formats:
now: "now"
singular:
seconds: "a second",
minutes: "a minute",
hours: "an hour",
days: "a day",
weeks: "a week",
months: "a month",
years: "a year",
,
plural:
seconds: "amount seconds",
minutes: "amount minutes",
hours: "amount hours",
days: "amount days",
weeks: "amount weeks",
months: "amount months",
years: "amount years",
,
,
);
);

Age also supports passing in a whitelist of allowed units (i.e. not showing units in weeks or months ever):


$('.age').age( units: ["days", "hours", "minutes"] );


jQuery Age - tracks dates and times as human readable text

No comments:

Post a Comment