indrimuska / angular-moment-picker

Angular Moment Picker is an AngularJS directive for date and time picker using Moment.js.
http://indrimuska.github.io/angular-moment-picker/
MIT License
527 stars 229 forks source link

Date bind to ng-model should be in the same format as format set in config #245

Open f-jost opened 6 years ago

f-jost commented 6 years ago

Hi,

In the config:

 momentPickerProvider.options({
        'locale': 'en',
        'format': 'YYYY/MM/DD'
      })

When user select the date in the picker, the output date that is bind to ng-model should be in the same format as format in the config, because actually if a user select 1985/03/02 the output date is "1985-03-01T23:00:00.000Z" and we have to re-format the date like user.momentDate.format('YYYY/MM/DD). So we must format two time the date, first in the config and second in the controller.

Another issue I encountered is if I set the locale in the config to 'fr' for example and that I set start-date option to moment('1985/01/01'), the picker display now the information in english and not in french, so we have to re-set the locale to the start date like this.startDate = moment('1985/01/01').locale('fr')