Created
June 21, 2013 18:41
-
-
Save failpunk/5833353 to your computer and use it in GitHub Desktop.
Simple Angular.js filter for using the moment.js library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('myFilters', []).filter('momentjs', function() { | |
return function(input, formatString) { | |
var m = moment(input) | |
, formatString = formatString || '' | |
, out = ''; | |
if(m && m.isValid()) { | |
if(formatString == 'calendar') { | |
out = m.calendar(); | |
} else { | |
out = m.format(formatString); | |
} | |
} | |
return out; | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment