角度js:使用角度过滤器分割日期,月份和时间

时间:2016-06-02 15:10:26

标签: javascript html angularjs

我正在尝试从ng-repeat

中的时间戳分割日期,月份(单词)和时间
$scope.notes.forEach(function(notes){
     $scope.notes.date = new Date(notes.date);
    });

在我看来我正在使用角度过滤器

 <div ng-repeat="note in notes">
Date: {{note.date | date:'dd'}}
Month:{{note.date | date:'mm'}}
</div>

这很好,但我还需要两个额外的东西

1.Month是单词,例如:(March)

2.时间参数例如:下午2点

角度滤波器是否可行?

注意: 时间戳示例2016-06-02T16:14:34+0530

1 个答案:

答案 0 :(得分:4)

对于月份,您可以使用以下内容对其进行过滤:

Month:{{note.date | date: 'MMMM'}}

根据您要格式化的方式,可以通过两种方式过滤时间:

Time:{{note.date | date: 'hh:a'}}

OR

Time:{{note.date | date: 'h:a'}}

以下是关于日期过滤的文档的link