Skip to content

Instantly share code, notes, and snippets.

@wallace7souza
Created March 25, 2015 20:44
Show Gist options
  • Save wallace7souza/8c649bd90fe13ce904cb to your computer and use it in GitHub Desktop.
Save wallace7souza/8c649bd90fe13ce904cb to your computer and use it in GitHub Desktop.
Angularjs dateTime format filter using moment.js
'use strict';
/**
* @ngdoc filter
* @function
* @description
* # dateTimeFormat
* Filter in the engagedAcademicApp.
*/
angular.module('myApp')
.filter('momentFormat', function () {
return function (dtOriginal,format2View,format2Read) {
if(format2Read===null || format2Read===undefined){
format2Read='YYYY-MM-DD h:mm:ss';
}
var x = moment(dtOriginal,format2Read);
return x.format(x.format(format2View));
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment