You can inject $filter as a dependency like you would do it for a controller, a service or a directive.
myApp.filter('myFilter',[ '$filter', function ($filter) {
return function (input) {
/**
Do your stuff
**/
return $filter('date')(myDate,myFormat);
}
}]);
On a side note, you should use angular.isDefined instead of != undefined
.
See the documentation of $filter and of date for more details