This is a migrated thread and some comments may be shown as answers.
Error when i retrieve date from kendo ui date-picker
1 Answer 4 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Renato asked on 16 Jul 2019, 12:43 PM
I'm trying to store one date in my database with the [Date Picker Component for Kendo Ui][1]

So, this component format my selected data like this:


I try to catch the return of the saved object and insert in my actual object, but i receive:

> Error: The 'value' should be a valid JavaScript Date instance. Check
> for possible resolution.

My component:
<kendo-datepicker [(value)]="ReferenciaMktDataDisponivel" ></kendo-datepicker>

Also tried:

    let dataDisponibilidade = new Date(this.formGroup.get('ReferenciaMktDataDisponivel').value)

My console.log of this date: `2019-07-17T00:00:00`

Can someone help me ?


1 Answer, 1 is accepted

Sort by
Dimiter Topalov
Telerik team
answered on 18 Jul 2019, 07:26 AM
Hi Renato,

The Kendo UI for Angular DatePicker and DateInput components can hold JavaScript Date object values only (i.e. - actual dates, as opposed to some serialized string representations). The recommended approach for binding the Date inputs to serialized data, coming from a remote service (for example) is to map the incoming data first so that the string values are converted to actual Date objects before binding the DatePicker/Input:

Here is a simple example demonstrating the observed error when the DatePicker is value-bound to a string, and the same DatePicker functioning properly when bound to a JavaScript Date object: // error when binding to a string // no error when binding to a Date

I hope this helps.

Dimiter Topalov
Progress Telerik
Get quickly onboarded and successful with your Telerik and Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Asked by
Top achievements
Rank 1
Answers by
Dimiter Topalov
Telerik team
Share this question