Luke Smith![]()
Provides a method Y.toRelativeTime(Date, refDate) to translate a past Date instance to a string like "2 days ago". If the optional second parameter is provided, the time delta is in reference to this date. Otherwise, the current date/time is used as the reference.
<script src="http://yui.yahooapis.com/3.1.0/build/yui/yui-min.js"></script>YUI({
//Last Gallery Build of this module
gallery: 'gallery-2009.10.27'
}).use('gallery-torelativetime', function(Y) {
var twitterposts = [ /* ... from elsewere ... */ ],
content = '',
entry, i, len;
for (i = 0, len = twitterposts.length; i < len; ++i) {
entry = twitterposts[i];
content = '<p>' + entry.status + ' (' + Y.toRelativeTime(entry.timestamp) + ')</p>' + content;
}
Y.one('#status').prepend(content);
});No forum posts for this module.
© 2010 YUI Library - Site Credits