• less than a minute ago
    function_context: Wow, this was really interesting!!
  • 2 minutes ago
    username1234: probably would've been faster in JVM
  • 10 minutes ago
    camelSuitCase: why not just use jquery....??????

Keep your timestamps up to speed.

Uptodate automatically updates the timestamps on your webpage to reflect their age over time.

When your users hang out on the same page for a while, they will no longer be exposed to outdated timestamps.

Get up and running in no time.

Uptodate requires a only few lines of setup, and the default settings will work for most cases.


1 Get your timestamps ready.

By default, uptodate will look for a value in data-time containing the number of milliseconds since epoch (00:00:00 UTC on 1970 January 1970), on elements of class uptodate

For example:
 Posted:
 <span class="uptodate" data-time="1367180233904">
     4 minutes ago
 <span>

2 Invoke the uptodate library

After some brief setup, all that's left is to call uptodate( )

You can pass optional parameters to this function, which will be covered below.

For example:
 <script src="js/uptodate.js">
 <script type="text/javascript">
     window.onload = function() {
         uptodate();
     };
 </script>

Customization options

You can set all (or none) of the following options when calling uptodate( )

klass:
Default: 'uptodate'
This is the class name matching all elements you wish to keep updated.
timestamp:
Default: function(el) {
  return parseInt(el.getAttribute('data-time'));
}
This is a function which, given an element, returns a value that is later consumed by new Date(__);
period:
Default: 60000
A number (in milliseconds) describe the time between updates. The default period is 1 minute (60 seconds).
formatter:
Default: time_ago_in_words /* see source */
A function which, given the timestamp (explained above), returns a formatted date string. The default function, time_ago_in_words produces strings such as "10 minutes ago" or "about 1 hour ago."