Skip to content

Instantly share code, notes, and snippets.

@cfjedimaster
Created January 30, 2014 21:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cfjedimaster/8720499 to your computer and use it in GitHub Desktop.
Save cfjedimaster/8720499 to your computer and use it in GitHub Desktop.
/* global angular */
angular.module('noteDbFilters', []).filter('dateFormat', function() {
return function(input) {
if(!input) return "";
input = new Date(input);
var res = (input.getMonth()+1) + "/" + input.getDate() + "/" + input.getFullYear() + " ";
var hour = input.getHours();
var ampm = "AM";
if(hour === 12) ampm = "PM";
if(hour > 12){
hour-=12;
ampm = "PM";
}
var minute = input.getMinutes()+1;
if(minute < 10) minute = "0" + minute;
res += hour + ":" + minute + " " + ampm;
return res;
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment