ngx-bootstrap: BsDatepickerConfig dateInputFormat doesn't work when patching values manually.
The DateInputFormatter works perfectly and displays the desired format when selecting the date through the datepicker but when I patch the value through the form like this: this.form.patchValue({ date_begin: new Date() }) it stays with the default MM/DD/YYYY format.
The datepicker:
bsDatepicker #d="bsDatepicker" [bsConfig]="{ dateInputFormat: 'DD-MM-YYYY' }"
Does anyone know a fix for this?
edit by @valorkin: solution https://github.com/valor-software/ngx-bootstrap/issues/2809#issuecomment-407677822
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 33
- Comments: 31 (1 by maintainers)
Links to this issue
Commits related to this issue
- Default date format change (related to https://github.com/valor-software/ngx-bootstrap/issues/2809) — committed to KrzysztofJaneczko/ngx-bootstrap-temp-fix by deleted user 7 years ago
the below steps will solve the issue
If you are using Date Range Picker then instead of “dateInputFormat” you should use “rangeInputFormat” in [bsConfig] . I had fixed by this option . Thanks .
To fix this issue you have to add formControlName to the input like this.
in component.ts
in component.html
@konasunny This correctly formats an initial date or one selected from calendar according to selected locale, but when using the input field to type in a date its seems to only accept mm.dd.yyyy.
You can test this behaviour in the locales example here https://valor-software.com/ngx-bootstrap/#/datepicker
Same problem here! Can it be fixed or done in other ways?
Same problem, pls pls fix.
So how should dateInputFormat work? I’ve have the following bsConfig on a daterangepicker
but it’s still formatted as MM/DD/YYYY
Yes this works!
value="{{birthDate.value | date: 'dd/MM/yyyy'}}"birthDate is FormControl. Thx 😃Any working workaround for template driven forms?
Thanks, Abhishek.
Is this issue fixed for bsDateRangePicker?
value="{{birthDate.value | date: 'dd/MM/yyyy'}}"I tried this and not worked for me because in case of date range pickerbirthDatecontains an array of date objects.The solution above works for initial value but typing new date in it still handles the input as mm/dd/yyyy. Anyone found a workaround for that case?
Yes @joaofsilva . 😐
Badly need this fixed! Does someone have a workaround?