I use bootstrap date picker and able to save date correctly to backend using reactive form. However, fetching the same date to UI, date showed is always one day behind.
CODE:
this.subjectPersonalform = this.formBuilder.group({dob_info: formBuilder.group({
dob: null,
dob_nv: ''
}, { validator: [_fmError.bothEmptyValidator, _fmError.bothCapturedValidator, _fmError.FutureDateValidator] }), });
Setting Data on UI:
let subject = JSON.parse(sessionStorage.getItem('SubjectPersonal'));
this.subjectPersonalform.patchValue({ dob_info: {
dob: subject['dob'] ,
dob_nv: subject['dob_nv']
},});
HTML:
<div class="form-group" formGroupName="dob_info">
<span>Date of Birth</span>
<div class="input-group">
<input type="text" class="form-control " bsDatepicker [bsConfig]="{containerClass:'theme-default'}"
formControlName="dob">
<select class="form-control col-sm-4" style="padding-right: 2px;padding-right: 2px;"
formControlName="dob_nv">
<option value="">Select</option>
<option *ngFor="let dobNv of dobNvs" [value]="dobNv.CODE">{{ dobNv.CODE}}</option>
</select>
</div>
<small class='text-danger'
*ngIf="subjectPersonalform.controls.dob_info.hasError('bothEmpty') && notSubmitted ">{{_fmError.getEmptyMessage()}}
</small>
<small class='text-danger'
*ngIf="subjectPersonalform.controls.dob_info.hasError('bothCaptured') && notSubmitted ">{{_fmError.getBothCapturedMessage()}}
</small>
<small class='text-danger'
*ngIf="subjectPersonalform.controls.dob_info.hasError('futureDate') && notSubmitted ">{{_fmError.getFutureDateMessage()}}
</small>
</div>
Data displayed on UI is -> 11/17/2019
Have found couple of issues reported on the same line, but solutions mentioned are not solving my issue. Any help is highly appreciated..!.. Thanks in advance.