我有一个棱角分明的应用程序,y从datepicker ui.bootstrap保存日期,我想过滤日期并显示可读取的日期。

例:
2014-04-17T07:00:00.000Z至4/14/2014或其他选项

谢谢

最佳答案

使用日期的角度过滤器。

{{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

07-25 23:38
查看更多