jQuery timer, ajax, and "nice time"
- by Mil
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.