Angularjs filter change date format in controller

By Hardik Savani | January 31, 2019 | Category : Angular

In this post, i will show you how to change date format in angularjs controller. if you need to change date format in html then you can use date filter, but in controller you need to change date formate like yyyy-mm-dd to dd/MM/yyyy than how you can do it.

you can change date formate using $filter('date')(date format timezone) in angular js controller.

Some days ago, someone ask me in comment. can you suggest me to change date formate in angular controller. he has date string and he wanted to change formate. so you don't require to convert string, but you can do it directly by using $filter in your controller.

Just see this example and code.


<!doctype html>



<title>Angularjs filter change date format in controller -</title>

<script src=""></script>


<body ng-app='myapp'>

<div ng-controller="myCtrl">


<p><strong>{{ item }}</strong></p>



<script type="text/javascript">

var app = angular.module('myapp', []);

app.controller('myCtrl', ['$scope', '$http', '$filter', function ($scope, $http, $filter) {

$scope.item = $filter('date')('2019-02-13', "dd/MM/yyyy");




I hope it can help you...

Hardik Savani
My name is Hardik Savani. I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. 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, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.
Follow Me: Github Twitter
***Do you want me hire for your Project Work? Then Contact US.

We are Recommending you: