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.
Uptodate requires a only few lines of setup, and the default settings will work for most cases.
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>
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>
You can set all (or none) of the following options when calling uptodate( )
Default: 'uptodate'This is the class name matching all elements you wish to keep updated.
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(__);
Default: 60000A number (in milliseconds) describe the time between updates. The default period is 1 minute (60 seconds).
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."
Uptodate was created by me, Jordan Scales. I hope it makes your life a little bit easier.
Uptodate is MIT Licensed (see LICENSE.txt)
To contribute to uptodate, please do the following: