The question is how to format a JavaScript Date
as a string stating the time elapsed similar to the way you see times displayed on Stack Overflow.
e.g.<
Might be an overkill in this case, but if the opportunity shows moment.js is just awesome!
Moment.js is a javascript datetime library, to use it for such scenario, you'd do:
moment(yourdate).fromNow()
http://momentjs.com/docs/#/displaying/fromnow/
2018 addendum: Luxon is a new modern library and might be worth a look!