Skip to content

Instantly share code, notes, and snippets.

View Spittal's full-sized avatar

Jamie Spittal Spittal

View GitHub Profile
@Spittal
Spittal / Format Time Angular Filter
Created July 31, 2014 22:27
Angular Time Filter that takes milliseconds and returns it as full minutes and seconds. For example: 60000 = 1:00, 6000000 = 100:00, 6000000 = 1:40:00 (withHour = true)
.filter('formatTime', function() {
return function(milliseconds,withHour) {
var seconds = parseInt((milliseconds/1000)%60);
var minutes = parseInt((milliseconds/(1000*60))%60);
var hours = parseInt((milliseconds/(1000*60*60))%24);
var out = "";
minutes = (parseInt(minutes) + (60 * parseInt(hours)));
minutes = (minutes < 10) ? "0" + minutes : minutes;
seconds = (seconds < 10) ? "0" + seconds : seconds;