Two way data binding changes the Kind of the Model DateTime property

Hello,

I get data out of a database using Entity Framework. The values are mapped to a model.

The date values all have Kind set to UTC as this is how I would like to store the dates.

If I use @bind-Value to bind the property of a class to the EjsDateTimePicker control the control correctly presents the date according to the locale.

However, it changes the Kind property of the DateTime object on the model to Local and changes the time accordingly.

For instance, it receives: {05/13/2020 17:00:00} UTC, but returns {05/13/2020 18:00:00} Local. But because the database assumes all dates are UTC it is stored incorrectly. 

Is there a way to keep the model property as the original Kind and value, and have the EjsDateTimePicker present the date and time according to the locale, so that when the values are returned to the database they are correct?

Thank you for your time.

1 Reply

SP Sureshkumar P Syncfusion Team March 17, 2020 06:44 AM UTC

Hi Robert, 
 
Greetings from Syncfusion support. 
 
Based on your shared information, we suspect that you have one-hour difference between server and client-side component. So, we suggest you use our ServerTimezoneOffset property to resolve your issue.  
 
Kindly refer the below code example. 
 
<EjsDateTimePicker TValue="DateTime?" @bind-Value="@DateValue1" ServerTimezoneOffset="+5.50"></EjsDateTimePicker> 
 
In the above example, we have added +5.50 for server in IST time zone. Similarly you need to add the offset value based on the timezone in server machine. 
 
Regards, 
Sureshkumar P 


Loader.
Up arrow icon