views:

162

answers:

1

So for this is what I've got:

$(document).ready(function () {
$("#div p").load("/update/temp.php");
function addOne() {
var number = parseInt($("#div p").html());
return number + 1;
}
setInterval(function () {
$("#div p").text(addOne());
}, 1000);
setInterval(function () {
$("#geupdate p").load("/update/temp.php");}
,10000);
});

So this grabs a a UNIX timestamp from temp.php and puts into into #div p, and then adds 1 to it every second, and then every 10 seconds it will check the original file to keep it up to speed.

My problem is that I need to format this UNIX timestamp into a format such as "1 day 3 hours 56 minutes and 3 seconds ago", while also doing all the incrementation and ajax calls. I'm not very experienced with jquery/javascript, so I might be missing something basic.

A: 

http://www.datejs.com/ does everything you could possibly want to do with dates in javascript. The first available download is out of date, but the SVN version is fine.

TRiG