How to Change Date Format using Date Filter in AngularJS?
AngularJS provides several filter for developing. AngularJS date filter through you can change date format as you want like yyyy-mm-dd, dd-MM-yyyy, MM-dd-yyyy etc. In bellow example you could understand very well date helper to how to use date filter in Angular JS.
In this example i have one array with date(yyyy-mm-dd date format) and date format will be convert into dd-mm-yyyy using date filter.
Example
<html lang="en-US">
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="customersCtrl">
<table>
<tr>
<th>Language</th>
<th>Date</th>
</tr>
<tr ng-repeat="x in names">
<td>{{ x.language }}</td>
<td>{{ x.date | date: 'dd-MM-yyyy' }}</td>
</tr>
</table>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
$scope.names = [
{'language': 'PHP', 'date': '2016-06-01' },
{'language': 'Laravel', 'date': '2016-06-02'},
{'language': 'Angular JS', 'date': '2016-06-05'},
];
});
</script>
</body>
</html>
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- AngularJS Check and Uncheck All Checkboxes Example
- PHP AngularJS Populate Dynamic Dropdown Example
- PHP AngularJS Add Remove Input Fields Dynamically Example
- AngularJS Ajax Autocomplete Using Typeahead in PHP Example
- AngularJS Convert Comma Separated String to Array Example
- How to Hide Div After Some Time in AngularJS?
- How to Call Function on Page Load in AngularJS?
- AngularJS Tooltip using UI Bootstrap tpls HTML Example
- AngularJS Simple Datepicker Directive Example Tutorial
- AngularJS Sorting(using Orderby Filter) Table Data Example
- AngularJS - How to Limit String Length using Filter?
- AngularJS - How to Capitalize the First Letter of Word Example
- How to Remove HTML Tags from String in AngularJS?
- PHP AngularJS CRUD with Search and Pagination Tutorial