title: Formatting and pretty printing dates with jquery
body: <p>I need to display dates in a couple different ways in an app built with jquery.</p>
  
  <p>In some situations, I need the typical "yyyy-mm-dd hh:mma" type of formatting, with all of it's different permutations. In other cases, I need to show dates "pretty printed" similar to how StackOverflow does them:</p>
  
  <ul>
  <li>5 seconds ago</li>
  <li>12 minutes ago</li>
  <li>3 hours ago</li>
  <li>yesterday</li>
  <li>2 days ago</li>
  </ul>
  
  <p>My application already uses JQuery UI DatePicker which includes a formatDate() function, but as far as I can tell, there is no way to use it outside of the datepicker. I want to format dates that aren't associated with a datepicker. Is it possible to do this using DatePicker?</p>
  
  <p>The <a href="http://datejs.com/" rel="noreferrer">DateJS</a> library can parse dates like "12 minutes ago", but as far as I can tell, it cannot take a Date object and format strings like this. It can format the typical "yyyy-mm-dd" types of formats. This library seems pretty heavy as well.</p>
  
  <p>John Resig's <a href="http://ejohn.org/blog/javascript-pretty-date/" rel="noreferrer">Pretty Dates</a> looks like it can provide the pretty printing ("2 hours ago"), but it doesn't do the standard formatting.</p>
  
  <p>Is there not a single plugin that can do all of this? Is there a way to leverage the DatePicker code so I don't have to load multiple codebases that do the same things?</p>