ItSolutionStuff.com

How to Change Date Format using Date Filter in AngularJS?

By Hardik Savani • November 5, 2023
Angular

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>

Tags: Angular
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

AngularJS Check and Uncheck All Checkboxes Example

Read Now →

PHP AngularJS Populate Dynamic Dropdown Example

Read Now →

PHP AngularJS Add Remove Input Fields Dynamically Example

Read Now →

AngularJS Ajax Autocomplete Using Typeahead in PHP Example

Read Now →

AngularJS Convert Comma Separated String to Array Example

Read Now →

How to Hide Div After Some Time in AngularJS?

Read Now →

How to Call Function on Page Load in AngularJS?

Read Now →

AngularJS Tooltip using UI Bootstrap tpls HTML Example

Read Now →

AngularJS Simple Datepicker Directive Example Tutorial

Read Now →

AngularJS Sorting(using Orderby Filter) Table Data Example

Read Now →

AngularJS - How to Limit String Length using Filter?

Read Now →

AngularJS - How to Capitalize the First Letter of Word Example

Read Now →

How to Remove HTML Tags from String in AngularJS?

Read Now →

PHP AngularJS CRUD with Search and Pagination Tutorial

Read Now →