1
$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

6
  • I think that adding more code would be useful, especially the controller and the view. Commented Oct 5, 2016 at 7:00
  • Did you log your $scope.startDate ? Commented Oct 5, 2016 at 7:47
  • Could you show us the $scope.startDate ? Commented Oct 5, 2016 at 7:53
  • $scope.startDate = new Date($scope.schemeInfo.schemeStartDate); Commented Oct 5, 2016 at 9:14
  • @RajatLutade Why have you unaccepted the answer ? Commented Oct 6, 2016 at 13:04

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.