I have an API which returns the date in this format 2018-12-24T16:00:00.000Z (ISO string). I am using Angular, Kendo UI and Typescript.
The problem that I am facing is the date is not getting bound to the Kendo date picker. I have read the documentation to integrate with JSON but I failed to apply it to my circumstances. And most of the solution in the Google use Javascript.
API call
"valueJson": {
"startDate": "2018-12-24T16:00:00.000Z"
}
component.ts
constructor(private fb: FormBuilder,
private service: PromotionsService, ) {
this.date = new Date();
}
ngOnInit() {
this.myForm = this.fb.group({
code: ["", [Validators.required]],
name: "Please Select",
customFieldDtoList: this.fb.array([
this.fb.group({
paramName: "details",
valueJson: this.fb.group({
category: "Please Select",
startDate: this.date,
endDate: this.date,
values: 0
}),
updatedDate: this.date
})
])
});
}
component.html
<div class="col-6" formArrayName='customFieldDtoList'>
<div formGroupName=0>
<div formGroupName="valueJson">
<p>Start Date</p>
<kendo-datepicker formControlName="startDate" style="width: 100%;" ></kendo-datepicker>
</div>
</div>
</div>
Upon using {{ myForm.value | json }} (output) to see the data, the 2018-12-24T16:00:00.000Z value can be displayed, however is not displayable by the date picker.
How do I change this ISO string and make it readable by the date picker?