This is a migrated thread and some comments may be shown as answers.

date-picker added one day

5 Answers 809 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 14 May 2018, 08:00 PM

Why the output of this line new FormControl(new Date(2018, 05, 14)), 2018/05/15? Why it add a day to the date?


5 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 15 May 2018, 06:21 AM
Hello,

The JavaScript Date object uses zero-based month values. With the given configuration, I do believe that the resulting date will be with +1 month than the desired one. The day value should stay the same. Our tests shows that indeed this is the case.

https://plnkr.co/edit/95vOpROaZYfe9kXfutZd?p=preview

Could you let me know if I am missing something?

As a side note, Typescript compiler doesn't parse zero padded numbers, like ''05", and will throw an error. The defined date should have the following params in our case:

new Date(2018, 4, 14)

Regards,
Georgi Krustev
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Patrick
Top achievements
Rank 1
answered on 15 May 2018, 02:33 PM

ignore the 0, my question is why the new date will end up + 1 day or month or whatever. How to prevent that

birthDate: new FormControl(new Date(2018, 4, 14)) //2018-05-14T00:00:00

0
Georgi Krustev
Telerik team
answered on 16 May 2018, 07:41 AM
Hi,

My observations show that the component correctly displays the day value. In the above example the provided Date instance with `14` day will be diplsayed as `14` value in the input.

Could you modify the demo I've shared in order to demonstrate the issue? Also in what timezone and browser is tested the component?

Regards,
Georgi Krustev
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Patrick
Top achievements
Rank 1
answered on 27 Jun 2018, 01:38 PM

Ok. This is very likely related to the timezone. Is there an option to set the timezone to EST instead of UTC by default?

 

Thanks,

Bryian Tan

0
Accepted
Daniel
Telerik team
answered on 29 Jun 2018, 10:53 AM
Hеllo,

The datepicker does not perform any timezone conversion. Is the date shown differently in the datepicker? From the formatted date(2018-05-14T00:00:00) that you provided it seems the Date is converted to JSON in which case the time will be converted to UTC. If this is the case then you can avoid the conversion by formatting the date before converting the data to JSON - example.

Regards,
Daniel
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
General Discussions
Asked by
Patrick
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Patrick
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or