Search code examples
angularjsangular-ui-datepicker

How to change date format from mm/dd/yyyy to dd/mm/yyyy?


I am using this library. I am having trouble converting the date format. When I pick a new date it should display date in dd/mm/yyyy


Solution

  • <input type="text" ui-date-format="dd/mm/yy" .../>
    

    EDIT:

    If you want the date on the input to appear in dd/mm/yy format as well, you need to init dateOptions with the format:

    $scope.dateOptions = {
        dateFormat: 'dd/mm/yy',
    }
    

    And HTML:

    <input type="text" ui-date-format="dd/mm/yy" ng-model="ngModel" ui-date="dateOptions"/>
    

    updated fiddle