Skip to content

Instantly share code, notes, and snippets.

@farnabaz
Created May 23, 2015 11:30
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 farnabaz/d4bdee0f51a890b2266b to your computer and use it in GitHub Desktop.
Save farnabaz/d4bdee0f51a890b2266b to your computer and use it in GitHub Desktop.
Simple Angular timer filter
// usage {{ 122 | timer }}
.filter("timer", function () {
return function (time) {
var sec = time % 60,
min = parseInt(time/60) % 60,
hou = parseInt(time/3600) % 60
sec < 10 && (sec = '0'+sec)
min < 10 && (min = '0'+min)
hou < 10 && (hou = '0'+hou)
return hou+":"+min+":"+sec
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment