Angularjs:时间戳UTC格式的时间与日期帮手 [英] Angularjs: timestamp to formatted UTC time with date helper

查看:984
本文介绍了Angularjs:时间戳UTC格式的时间与日期帮手的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找的想法如何与AngularJS日期帮手格式化unix时间戳?

I'm looking for idea how to format unix timestamp with AngularJS date helper?

官方文档,只有字符串输入说明(如果没有时区是在指定字符串输入,时间被认为是在本地时区),但对于时间戳?任何提示吗?

In official documentation, there is only explanation for string inputs (If no timezone is specified in the string input, the time is considered to be in the local timezone), but what about timestamp? Any hint?

推荐答案

我已经找到了一些解决方案,定制过滤器和momentjs库:

I've found some solution with custom filter and momentjs library:

app.filter('moment', function() {  
    return function(input, format) {  
        return moment(parseInt(input)).utc().format(format);  
    };  
});  

这篇关于Angularjs:时间戳UTC格式的时间与日期帮手的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆