AngularJS UnixTime到DateTime格式与日期过滤器失败 [英] AngularJS UnixTime to DateTime Format with date filter failed

查看:209
本文介绍了AngularJS UnixTime到DateTime格式与日期过滤器失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解到,可以通过使用此帖子中的日期过滤器将unix时间戳转换为日期:
AngularJS。转换标记值(unix时间到人类可读的时间)

I learned that one can transform a unix time stamp into a date by using date filter from this post: AngularJS. Convert tag value (unix time to human readable time)

但是我不能用我的转换...

But I can not convert mine with it...

<td>{{contract.start_date_unix | date:'MM-dd-yyyy'}}</td>

里面的 contract.start_date_unix ,它的价值在 1406779200

我使用 checker 它正好显示了我想要的东西:
星期四,2014年7月31日04:00:00 GMT (但是,我想要的格式是MM-dd-yyyy,日期是正确的,这是我试图在这里证明的)

I checked it with a checker that it shows exactly what I want: Thu, 31 Jul 2014 04:00:00 GMT (but of course, the format I want is MM-dd-yyyy, the date is correct and that's what I try to prove here)

但是,当我做上面的日期过滤器时,它只会显示 01-17-1970 01-16-1970 ...

But when I do the date filter above, it will only show 01-17-1970 or 01-16-1970...

什么可能是因为这个问题吗?

What could be the issue cause this?

推荐答案

显示的时间是时代,而不是实际的日期。请阅读您的问题中的链接,回答是在其中一个链接。

the time shown is epoch and not actual date. please read the links in your question, answer is there in one of the links.

您需要将时间乘以1000。

you need to multiply the time by 1000.

<td>{{contract.start_date_unix * 1000 | date:'MM-dd-yyyy'}}</td>

这篇关于AngularJS UnixTime到DateTime格式与日期过滤器失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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