Moment.js is a useful script library for to "Parse, validate, manipulate,and display dates and times in JavaScript". A useful function is showing the duration elapsed from a date in the past to today / now using fromNow() function.. Here is how to set a 'Post' date and display how long has passed since it was posted in a div element.

Limitations of using Moment.js

First off moment.js is an external JavaScript library and so unless you intend on using the range of other date/time functions then consider whether the extra 18.2k (minified) load is worthwhile over standard JavaScript functions. Also the date is displayed to the nearest month or year in this example and that may not be precise enough. Otherwise moment.js is often considered the best free online script to manipulate date and time.