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屋!
查看全文