datefilter

How to use angular js date filter?

AngularJS date filter is used to convert a date into a specified format. When the date format is not specified, the default date format is ‘MMM d, yyyy’.

Ex:

  <body> 

        <div ng-app=”gfgApp” ng-controller=”dateCntrl”> 

            <p>{{ today | date : “dd.MM.y” }}</p> 

        </div> 

        <script> 

            var app = angular.module(‘gfgApp’, []); 

            app.controller(‘dateCntrl’, function($scope) { 

                $scope.today = new Date(); 

            }); 

        </script> 

    </body>

Explanation:

This code gives the current date with filter value. It will display the date into a respective format.

Leave a comment

Your email address will not be published. Required fields are marked *