DateTimePicker show date incorrect

2 Answers 144 Views
DateTimePicker
Thi Xuan Thao
Top achievements
Rank 1
Thi Xuan Thao asked on 08 Mar 2023, 06:39 PM

Hi ,

Today is 3/08/2023. I tried to create 2  DateTimePicker  controls  as code below 

const effDate2 = new Date( "2023-03-03");
   

consttoday = newDate();

 <div className="mb-3">
                  <Label> Effective Date </Label>
                  <DatePicker name = 'effectiveDate' value ={effDate2} onChange={handleDatePickerChange} />
                 
                </div>
                <div className="mb-3">
                  <Label> Today  </Label>
                  <DatePicker name = 'today' value ={today} onChange={handleDatePickerChange} />
                 
                </div>

 

The Effective Date control show :   while the Today Date show  

 

Can you pls advise me why the value of Effective Date changed ? 


Thanks,
Thao Phan

 


Nitin
Top achievements
Rank 1
commented on 24 May 2023, 04:09 PM

I am also observing the similar issue. Also on mouse hover on back months, it is showing the incorrect date on mouse hover.

2 Answers, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 10 Mar 2023, 04:15 PM

Hello, Thao Phan,

I tested the provided snippets but the DatePickers show the passed dates properly at my side:

Can you test the demo below and see whether you get the same result as well?

Regards,
Vessy
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/.

Thi Xuan Thao
Top achievements
Rank 1
commented on 10 Mar 2023, 04:24 PM

Hi Vessy,

Here is what I run on my Chrome browser .

 

Thanks,
Thao Phan 

Vessy
Telerik team
commented on 14 Mar 2023, 01:22 PM

Hi, Thao,

Thank you for the provided screenshot.

Most probably the different result is caused due to a difference in the local time in which the Date() object is initialized. Can you try using an `IntlProvider` provider in order to load a specific locale to the page and let me know the result?:

You can test this approach here:

 

Thi Xuan Thao
Top achievements
Rank 1
commented on 14 Mar 2023, 01:41 PM

Hi Vessy,

I tried your example on 2 computers . One is my company laptop and one is my personal one. Thay have the same result . Pls have a look on my screen shot 

Thanks,
Thao Phan

0
Vessy
Telerik team
answered on 26 May 2023, 03:23 PM

Hi, guys,

The date returned by `new Date()` depends on the date format passed to the Date() constructor and it defaults to UTC. If you are in a different time zone, you can use a more-precised format like `new Date('2016-09-05T00:00')` to create the date object in local time. You can read details on this matter here:

For example, you can try the following syntax:

Regards,
Vessy
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Kendo family, check out our getting started resources!

Tags
DateTimePicker
Asked by
Thi Xuan Thao
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Share this question
or