Angularjs秒到时间过滤 [英] Angularjs seconds to time filter
本文介绍了Angularjs秒到时间过滤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用Angularjs。
I'm using Angularjs.
我有一串数字,例如: 237
。这意味着秒。我需要更改为: 2:34
或 3:42:54
。
I have string of number, example: 237
. It means seconds. I need it to change to: 2:34
, or 3:42:54
.
我需要几秒钟的时间过滤。我应该怎么做?
I need seconds to time filter. How should I make it?
谢谢。
推荐答案
像这样:
app.filter('secondsToDateTime', [function() {
return function(seconds) {
return new Date(1970, 0, 1).setSeconds(seconds);
};
}])
html:
<b>{{seconds | secondsToDateTime | date:'HH:mm:ss'}}</b>
这篇关于Angularjs秒到时间过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文