AngularJS - How do you convert milliseconds to xHours and yMins

前端 未结 9 945
小鲜肉
小鲜肉 2020-12-14 18:26

I\'ve a requirement where I want to convert milliseconds to xHours and yMins in AngularJS.

For ex. 3600000 should be displayed as 1h 0m.

I tried using

9条回答
  •  星月不相逢
    2020-12-14 18:54

    (function () {
        'use strict';
    
        angular
            .module('module_name')
            .filter('secondsToDateTime', secondsToDateTime);
    
        function secondsToDateTime() {
            return function(seconds) {
                return new Date(1970, 0, 1).setSeconds(seconds);
            };
        }
    })();
    
    
    {{seconds | secondsToDateTime | date:'HH:mm:ss'}}
    

提交回复
热议问题