Angular ng-repeat 日期格式 [英] Angular ng-repeat date formatting

查看:26
本文介绍了Angular ng-repeat 日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 angular ng-repeat 来显示数据数组,其中包括一些作为日期的列,但是格式化日期以便它们呈现给用户的最佳方法是什么?先感谢您.

I am using angular ng-repeat to display an array of data including some columns which are dates but what is the best way to format the dates so they are presentable to the user? Thank you in advance.

日期看起来像这样2016-01-14T08:00:00.000Z

DATES LOOK LIKE THIS IN VIEW 2016-01-14T08:00:00.000Z

想要这种格式2016 年 1 月 14 日

WANT THIS FORMAT January 14, 2016

<td width="65%" class="joinedDate">{{user.created_at}}</td>

推荐答案

如果你的格式像你的日期(2016 年 1 月 14 日),你可以使用

if you format like your date (January 14, 2016) you can use

<td width="65%" class="joinedDate">{{user.created_at | date:'MMMM dd, yyyy'  }}</td>

using date : 'medium' 默认日期时间,如 Oct 29, 2010 9:10:23 AM

using date : 'medium' default date time like Oct 29, 2010 9:10:23 AM

<td width="65%" class="joinedDate">{{user.created_at |date:'medium'}}</td>

更多了解https://docs.angularjs.org/api/ng/filter/日期

这篇关于Angular ng-repeat 日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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