我有一个有角度的应用程序,并且从datepicker ui.bootstrap中保存日期,我想过滤日期并显示可读日期..
实施例: 2014-04-17T07:00:00.000Z至2014/4/14或其他选项
由于
答案 0 :(得分:3)
使用日期的角度过滤器。
{{date | date:'MM-dd-yyyy HH:MM:ss}}
请参阅以下链接 - http://docs.angularjs.org/api/ng.filter:date
示例( Working Example )
<强> HTML 强>
<div ng-app='myApp' ng-controller="ArrayController">
<li ng-repeat="arr in records ">
{{arr.date| date:'MM/dd/yyyy'}}
</li>
</div>
<强>脚本强>
var app = angular.module('myApp', []);
app.controller('ArrayController', function ($scope) {
$scope.records = [{
name: 'sohn',
phone: '555-1212',
age: 10,
date: '2014-11-12T07:00:00.000Z'},
{
name: 'Mary',
phone: '555-9876',
age: 19,
date: '2014-05-17T07:00:00.000Z'},
{
name: 'Mike',
phone: '555-4321',
age: 21,
date: '2014-04-17T07:00:00.000Z'},
{
name: 'Adam',
phone: '555-5678',
age: 35,
date: '2014-09-01T07:00:00.000Z'},
{
name: 'Julie',
phone: '555-8765',
age: 29,
date: '2014-10-21T07:00:00.000Z'},
{
name: 'Julie',
phone: '555-8765',
age: 29,
date: '2014-11-12T07:00:00.000Z'},
{
name: 'arlina',
phone: '555-8765',
age: 29,
date: '2014-07-07T07:00:00.000Z'},
{
name: 'Mary',
phone: '555-8765',
age: 29,
date: '2014-06-07T07:00:00.000Z'}
];
});
<强>输出强>
11/12/2014
05/17/2014
04/17/2014
09/01/2014
10/21/2014
11/12/2014
07/07/2014
06/07/2014