1

I would like to change format of date input field from dd/mm/yyy to dd.mm.yyyy Is it possible and how and is there any chance to get that datepicker working in another browsers as well?

<body ng-app="myApp">
    <div ng-controller="MyCtrl">
      <input type="date" ng-model="date" value="{{date}}">
        <p>{{date}}</p>
      <input type="time" ng-model="time" value="{{time}}">    
    </div>

How date looks now in Chrome Browser

2
  • This is not an AngularJS problem per se, but a browser specific problem. Basically, the value is always in the ISO format (YYYY-MM-DD), while the displayed date (in the pop-up) is formatted in regard to the system/browser locale settings. Commented Jun 24, 2015 at 12:48
  • @Sami Maybe this thread helps. Commented Jun 24, 2015 at 12:50

1 Answer 1

2

you can use custom filter for it as below

        <div ng-app="myApp">
           <div ng-controller="myCtrl">
             <p>{{date | divideByPoint}}</p> // displays as dd.mm.yyyy(21.12.2014)
          </div>
       </div>

below filter : divideByPoint

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

 //controller
      app.controller('myCtrl',myCtrl);

         myCtrl.$inject = ["$scope"];

         function myCtrl($scope){
            $scope.date = "21/12/2014"
       }

  //filter

    app.filter('divideByPoint',function(){

     var pattern = /\//g;  
        return function(input) {
              return input.replace(pattern,'.');
           }

     })

https://jsfiddle.net/shushanthp/9yes55L5/

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

1 Comment

How to use filter with input type="date"?

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.