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.
- Host: GitHub
- URL: https://github.com/thinkphp/prettydate
- Owner: thinkphp
- Created: 2011-05-14T19:02:37.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2011-05-15T06:57:01.000Z (over 14 years ago)
- Last Synced: 2024-04-14T14:54:28.492Z (almost 2 years ago)
- Language: JavaScript
- Homepage: http://thinkphp.github.com/prettydate/
- Size: 127 KB
- Stars: 6
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
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/).

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
- @john just happened here
posted Sun May 14 20:35:28 +0000 2011 - @code just happened here
posted Sun May 14 19:15:28 +0000 2011 - @php just happened here
posted Sun May 14 10:54:28 +0000 2011 - @mootools just happened here
posted Sun May 14 21:40:28 +0000 2011 - @jquery just happened here
posted Sun May 14 12:54:28 +0000 2011 - @yui just happened here
posted Sun May 14 19:54:28 +0000 2011
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);
});