Template tag to convert number of seconds into mm:ss format

1
2
3
4
5
@register.filter()
def formatSeconds(s):
    mins = math.floor(s / 60);
    secs = math.floor(s - (mins * 60)); 
    return "%d:%02d" % (mins, secs);

More like this

  1. date range by mackenzie_kearl 5 years, 3 months ago
  2. format_thousands by cootetom 1 year, 10 months ago
  3. Human format Date representation by sachingupta006 1 year, 2 months ago
  4. Email and phone templatetag obfuscator by sunn 3 years, 9 months ago
  5. Simple template tag to do |stringformat filter with format from a variable by leopd 2 years, 1 month ago

Comments

(Forgotten your password?)