An open API service indexing awesome lists of open source software.

https://github.com/thinkphp/prettydate

This plugin MooTools provides a way to format JavaScript dates in the style of Twitter's timeline.
https://github.com/thinkphp/prettydate

Last synced: 3 months ago
JSON representation

This plugin MooTools provides a way to format JavaScript dates in the style of Twitter's timeline.

Awesome Lists containing this project

README

          

PrettyDate
==========

This plugin provides a way to format JavaScript dates in the style of Twitter's timeline:
"just now", "about 8 minutes ago","about 11 hours ago","yesterday".
The method is, originally, written by [John Resig](http://ejohn.org/blog/javascript-pretty-date/).

![Screenshot](http://farm4.static.flickr.com/3229/5721430624_80ab38a116.jpg)

How to use
----------

First you must to include the JS files in the head of your HTML document.

#HTML

google.load("mootools", "1.3");

You need to specify the source of the ISO8601-date.

#HTML

Then you can apply the method.

#JS
window.addEvent('domready', function() {
new PrettyDate($$("a.pretty"));
});

OR

//apply `prettyDate` method to those;
window.addEvent('domready', function() {
$$("a.pretty").prettyDate();
});


To localize this plugin overwrite the options.
ex: french localization:

#JS
window.addEvent('domready', function() {
var options = {
now : "a l'instant",
minute : "il y a 1 minute",
minutes : "il y a {x} minutes",
hour : "il y a 1 heure",
hours : "il y a {x} heures",
yesterday: " hier",
days : " il y a {x} jours",
weeks : " il y a {x} semaines"
};
$$('a.pretty').prettyDate(options);
});