Rajat Lutade
Rajat Lutade

Reputation: 73

Date Filter is not working in AngularJS..?

$scope.schemeInfo.schemeStartDate = $filter("date")($scope.startDate,"dd/MM/yyyy");

Its giving me not formatted output as

Mon Oct 10 00:00:00 PDT 2016

Upvotes: 1

Views: 831

Answers (1)

Supradeep
Supradeep

Reputation: 3266

Make sure your "$scope.startDate" is a date object.

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

app.controller('MyCtrl', ['$scope', '$filter', function($scope, $filter)
{
    $scope.myDate = new Date('Mon Oct 10 00:00:00 PDT 2016');
    $scope.myDateFiltered = $filter('date')($scope.myDate, 'dd/MM/yy');
}]);

Hope this helps.

FYI: Created the jsfiddle, here

Upvotes: 1

Related Questions