Last active
January 14, 2016 21:24
-
-
Save mattraykowski/61b417e60fbc4f1e9bd4 to your computer and use it in GitHub Desktop.
Moment Date Format for Angular
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
(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