g00fy- / angular-datepicker

calendar and datepicker directives for angular
MIT License
719 stars 420 forks source link

Issue when I try to input a date manually. #283

Open eduardonaguiar opened 8 years ago

eduardonaguiar commented 8 years ago

I creating a GUI and need the user can input the date both manually and selecting a date in datepicker. When I input the date manually de modelview value isn't setted. How do I can make it?

ahmadhsalim commented 8 years ago

I'm having the same issue. I set the format to be DD/MM/YYYY. When the user enters a date manually using keyboard, say, 03/12/2016 and then I click the date picker it shows the date as march 12th instead of dec 3rd. But when I pick a date on the date picker it displays the properly formatted date in the input box. It works on other date formats though.

shivasingh0101 commented 8 years ago

In the respective js file provide a format of 'YYYY/MM/DD' because moment.js reads it as the format i mentioned.

The code is as follows:

<input type="text" ng-model="$scope.dob" date-time name="dob" format="DD-MM-YYYY" auto-close="true" min-view="date" view="year">

$scope.dob = moment($scope.dob, "DD/MM/YYYY").format('YYYY/MM/DD');