Set relative time with timestamp

I was able to solve the problem once I knew that Scripted Fields existed so this is what I used to show how long ago the update was :

if(Math.round((new Date().getTime()-doc['@timestamp'].value)/1000)>7200){
   return Math.round((new Date().getTime()-doc['@timestamp'].value)/3600000) + " hours ago";
}else if(Math.round((new Date().getTime()-doc['@timestamp'].value)/1000)>3600){
   return Math.round((new Date().getTime()-doc['@timestamp'].value)/3600000) + " hour ago";
}else if(Math.round((new Date().getTime()-doc['@timestamp'].value)/1000)>120){
   return Math.round((new Date().getTime()-doc['@timestamp'].value)/60000) + " minutes ago";
} else if(Math.round((new Date().getTime()-doc['@timestamp'].value)/1000)>60){
   return Math.round((new Date().getTime()-doc['@timestamp'].value)/60000) + " minute ago";
}else {
   return Math.round((new Date().getTime()-doc['@timestamp'].value)/1000)  + " seconds ago";
}