function local(a, b) {
var c = b - a;
if(c < 60) // seconds
{
document.write(Math.floor(c) + 'seconds ago');
}
else if(c >= 60 && c < 3600) // minutes
{
document.write(Math.floor(c/60) + 'minutes ago');
}
else if(c >= 3600 && c < 43200) // hours
{
document.write(Math.floor(c/3600) + 'hours ago');
}
else if(c >= 43200)
{
var d = new Date(a);
document.write(d);
}
}
function local(a, b) { var c = b – a; if(c < 60) //
Share
Just concatenate. For example, instead of:
Try this:
If you want the output floored (rounded down):