AngularJS Tutorial - Custom Date filter








The following code shows how to use Custom Date filter.

Example


<!DOCTYPE html>
<html  ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
</head><!--from   w  ww  . j  a v a2  s.com-->
<body>
  <body ng-app>
    <div ng-controller="MainCtrl">
        <input type="date"
               ng-model="date"
               value="{{ date | date: 'yyyy-MM-dd' }}" />
        <br/>{{ date | date: 'dd/MM/yyyy' }}
    </div>
</body>
<script type='text/javascript'>

function MainCtrl($scope) {
    $scope.date = new Date();
}
</script>
</body>
</html>

The code above is rendered as follows: