We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

DateTimePicker return UTC Date/Time?

Thread ID:

Created:

Updated:

Platform:

Replies:

141930 Jan 10,2019 07:23 PM UTC Jan 23,2019 05:56 AM UTC ASP.NET Core - EJ 2 5
loading
Tags: DataGrid
Michael Lambert
Asked On January 10, 2019 07:23 PM UTC

The app is using a legacy db where all the datetime fields are local (not using UTC as basis).  I've notice that the DateTimePicker returns the date/time  selected in the control  converted to UTC time upon update to the controller.  i.e. A user selects 1/1/19 12:00 in the control, but the controls returns 1/1/19 20:00 to the controller upon update.  I want it to just return 1/1/19 12:00.  Can I do that on the control or do I have to convert it back at the controller manually?

Mike

Deepa Loganathan [Syncfusion]
Replied On January 11, 2019 12:56 PM UTC

Hi Daniel,  
 
Thanks for contacting Syncfusion support.  
 
We have investigated the reported issue in Datetimepicker and tried to reproduce the reported issue with a simple test sample. Sorry, but we were unable to reproduce it while posting the selected value to server from DatetimepickerFor control and can confirm that the same value was posted in the controller.  
 
Please find the test sample from the below link.  
 
 
So kindly share us the below details that would help us to analyze and isolate the root cause of this issue.  
 
1.      View page, Model, ViewModel and controller pages of your application. 
2.      Are you using any stored procedure that might convert the DateTime values to its equivalent UTC?  
3.      Database language used in your application 
4.      A video that demonstrates the conversion in code behind, if possible 
 
Regards,  
Deepa L. 


Michael Lambert
Replied On January 11, 2019 09:22 PM UTC

Hi,
I'm using SQL as the DB backend. When the datasource is sent to the Grid the DateStart.Kind (field var) = unspecified, but on the update post the DateStart.Kind is changed to UTC which seem to lead to a timezone issue.

Please see attached for screen captures and code.

Thanks,
Mike

Attachment: SyncFDateIssue_e631a344.zip

Madhu Sudhanan P [Syncfusion]
Replied On January 18, 2019 10:32 AM UTC

Hi Michael, 

Sorry for the delayed response. 

We have validated the provided information and we suggest you to use the below way to achieve your requirement. In the below code example, we have converted date object into ISO string by using DataUtil.dateparse method in actionBegin event of Grid. 

Please refer the below code example for more information. 

<div> 
    <ejs-grid id="Grid" actionBegin="begin" toolbar="@(new List<string>() {"Delete" ,"Add", "Update", "Cancel" })" allowPaging="true"> 
        <e-grid-editsettings allowDeleting="true" allowEditing="true" allowAdding="true"></e-grid-editsettings> 
        <e-grid-columns> 
             . . . . .  
            <e-grid-column field="DateStart" headerText="OrderDate" type="dateTime" edit="@(new {create = "created", read = "readd", destroy = "destroyd", write = "writed"})" minWidth="20" maxWidth="500"></e-grid-column> 
        </e-grid-columns> 
    </ejs-grid> 
</div> 
 
<script> 
 
    function begin(args) { 
        if (args.requestType === 'save') { 
            // you can also convert date object as ISO string using below method to resolve the problem. 
 
            args.data['DateStart'] = ej.data.DataUtil.dateParse.addSelfOffset(new Date(args.data['DateStart'])).toISOString(); 
        } 
    } 

Regards, 
Madhu Sudhanan P 


Michael Lambert
Replied On January 22, 2019 07:03 PM UTC

Thanks Madh, that works!

Madhu Sudhanan P [Syncfusion]
Replied On January 23, 2019 05:56 AM UTC

Hi Michael, 
We are glad that your requirement has been achieved. 
Regards, 
Madhu 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;