Acá les dejo los codigo para que revisen
Código Javascript:
Ver original
function Actuliacr_hora(){ var Time = 0; var UNIX_timestamp = $("#localstreaming").attr("fecha-comentario"); var ID_timestamp = $("#localstreaming").attr("ID"); var a = new Date(); var TimeC = a.getTime().toString().substr(0, 10); var time_difference = TimeC - UNIX_timestamp ; var seconds = time_difference; var minutes = Math.round(time_difference / 60) ; var hours = Math.round(time_difference / 3600 ); var days = Math.round(time_difference / 86400 ); var weeks = Math.round(time_difference / 604800 ); var months = Math.round(time_difference / 2419200 ); var years = Math.round(time_difference / 29030400 ); setTimeout(Actuliacr_hora, 20000) if(seconds <= 20) { Time = "ahora"; }else if(seconds <= 60){ Time = "Hace " + seconds +" segundos"; } else if(minutes <=60) { if(minutes==1) { Time = 'Hace un minuto'; } else { Time = "Hace " + minutes +" minutos"; } } else if(hours <=24) { if(hours==1) { Time = 'Hace una hora'; } else { Time = "Hace " + hours +" horas"; } } else if(days <=7) { if(days==1) { Time = 'Hace una día'; } else { Time = "Hace " + days +" días"; } } else if(weeks <=4) { if(weeks==1) { Time = 'Hace una semana'; } else { Time = "Hace " + weeks +" semanas"; } } else if(months <=12) { if(months==1) { Time = 'Hace un mes'; } else { Time = "Hace " + months +" meses"; } } else { if(years==1) { Time = 'Hace un año'; } else { Time = "Hace " + years +" años"; } } $('.fech-comen_'+ID_timestamp).html(Time); } setTimeout(Actuliacr_hora, 5000)