December 2014
Intermediate to advanced
346 pages
6h 14m
English
The date filter is an extremely robust and customizable filter that can handle many different kinds of raw date strings and convert them into human readable versions. This is useful in situations when you want to let your server defer datetime processing to the client and just be able to pass it a Unix timestamp or an ISO date.
Suppose, you have your controller set up in the following fashion:
(app.js)
angular.module('myApp', [])
.controller('Ctrl', function ($scope) {
$scope.data = {
unix: 1394787566535,
iso: '2014-03-14T08:59:26Z',
date: new Date(2014, 2, 14, 1, 59, 26, 535)
};
});All the date formats can be used seamlessly with the date filter inside the template, as follows:
(index.html) <div ng-app="myApp"> ...
Read now
Unlock full access