Receive the wrong date in a Reactive form with kendo Datepicker & Angular

1 Answer 248 Views
DatePicker
hiba
Top achievements
Rank 1
hiba asked on 16 Jun 2021, 04:35 PM

I have a reactive form and I get the wrong date in the formControlName ( I receive the date chosen + 1 day ) 

This is the component html :

<form id="f"class="pt-2"[formGroup]="workAreaForm">

<kendo-datepicker  formControlName="startDate" [format]="'dd/MM/y'" placeholder="DD/MM/YYYY"      

></kendo-datepicker>

</form>

 

//And when I console workAreaForm.get('startDate').value it gives me the wrong date !!

1 Answer, 1 is accepted

Sort by
0
Slavena
Telerik team
answered on 18 Jun 2021, 01:57 PM

Hello Hiba,

Thank you for the provided code snippet. I tried reproducing the described problem but was unsuccessful in doing so. Here is a Stackblitz demo of my attempt:

https://stackblitz.com/edit/angular-bxysvj-b47new?file=app%2Fapp.component.ts

In the demo, date is initially set:

 public date: Date = new Date(2000, 2, 10);
However, the output in the DatePicker is 3/10/2000. In case you were referring to this difference, it is due to the specifics of the JavaScript Date object where the month is a zero-based value (zero indicating the first month of the year). If this is not the case, I would ask you to send us a runnable Stackblitz demo that shows the unwanted behaviour so that we could further investigate and see what causes it. I am looking forward to your reply.

Regards,
Slavena
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
DatePicker
Asked by
hiba
Top achievements
Rank 1
Answers by
Slavena
Telerik team
Share this question
or