Skip to content

Instantly share code, notes, and snippets.

@mattraykowski
Last active January 14, 2016 21:24
Show Gist options
  • Save mattraykowski/61b417e60fbc4f1e9bd4 to your computer and use it in GitHub Desktop.
Save mattraykowski/61b417e60fbc4f1e9bd4 to your computer and use it in GitHub Desktop.
Moment Date Format for Angular
(function() {
'use strict';
angular
.module('kd.common.components')
.filter('dateFormat', dateFormat);
/* @ngInject */
function dateFormat(moment) {
return filter;
function filter(value, format) {
var dateFormat = 'MM/DD/YYYY';
if(!_.isEmpty(format)) {
dateFormat = format;
}
if(_.isEmpty(value)) {
return 'Invalid Date';
}
return moment(value).format(format);
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment