Skip to content

Instantly share code, notes, and snippets.

@facultymatt
Created September 13, 2013 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save facultymatt/6556599 to your computer and use it in GitHub Desktop.
Save facultymatt/6556599 to your computer and use it in GitHub Desktop.
Directive to do a time ago with angular. Add "moment" : "latest" to your bower.json file.
<p>{{poast.created | fromNow}}</p>
angular.module('app').filter('fromNow', function() {
return function(date) {
var newDate = new Date(date*1000);
return moment(newDate).fromNow();
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment