YUILibrary - Open source JavaScript and CSS for building richly interactive software.
Fork YUI on GitHub
  • Home
  • Gallery
  • Forums
  • YUI 2
  • YUI 3
  • YUI Compressor
  • YUI Doc
  • More
  • Gallery Forums
  • Gallery Stats
  • Gallery Calendar
  • Register
  • Login

Modules

  • Home
  • Featured
  • Popular
  • New
  • All

Documentation

  • FAQ
  • Developer FAQ
  • Developer Guide
  • Module Setup

Tag Cloud

plugin jafl node ericf io form slideshow rgrove foxxtrot apipkin davglass caridy yui2 html5 lsmith jsonp event skinnable widget filter animation nzakas overlay adam port ajax

Context Navigation

    YUI Library is not responsible for bugs or support with this module. It is available as a free service. For support please contact the module owner with the provided links.

    toRelativeTime (gallery-torelativetime) on cdn

    Last Updated: 10/27/09
    + 1 -

    Luke Smith

    YUI Developer

    See 6 more by this user.

    Created: 10/25/09
    Last CDN Push: 10/27/09
    Build Tag: gallery-2009.10.27
    Project: YUI 3
    License: YUI BSD
    YUI Version: 3.0.0
    Free for use.

    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.

    • Tags:
    • lsmith
    • date
    • time
    • Download
    • Docs
    • Homepage
    • Bugs
    • Source
    • Example
    • Forum
    • History

    Code Sample

    <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);
     
    });

    Forum Posts

    No forum posts for this module.

    YUI Projects
    • All YUI Downloads
    • YUI 2
    • YUI 3
    • YUI Doc
    • YUI Compressor
    • YUILibrary.com
    • YUI Build Tool
    • YUI PHP Loader
    Pages & Links
    • All YUI Downloads
    • Git FAQ
    • Graded Browser Support
    • Contribute to YUI
    • Forum Stats
    • Gallery Stats
    • YUI Calendar
    Contribute
    • Submit a Bug
    • Request a Feature
    • Write Code
    • Meet the Team
    Follow YUI
    • on GitHub
    • on Twitter
    • on FriendFeed
    • on Facebook
    • on IRC
    • YUI Blog
    • YUI Theater
    • YUI Forums

    © 2010 YUI Library - Site Credits