How to get Grid and Form to send DateTime in the same format back to the server?

2 posts, 0 answers
  1. Kaan
    Kaan avatar
    7 posts
    Member since:
    May 2016

    Posted 23 Jun Link to this post


    I have an editor template (DATETIMEEDIT.cshtml) for date times, which I use in a Grid and also in an ordinary form:

    @model DateTime?
    @(Html.Kendo().DateTimePickerFor(m => m)
    .HtmlAttributes(new { style = "width:100%;" })


    The editor is bound to the Grid in this way:

    var c = columns.Bound(fieldName);
    c.Format("{0:dd.MM.yyyy HH:mm}");


    And this is how the editor is integrated into the HTML form:

    @Html.EditorFor(v => dateTime, "DATETIMEEDIT", fieldName)


    When I update the date and time, the Grid sends it back to the server as "3/21/2016 5:35:00 PM", and the form as "21.03.2016 17:35".

    However, I need a reliable DateTime exchange format between the server and the client. "dd.MM.yyyy HH:mm" (24 hour) would be ok, but any other consistant solution would be alright too because if the server receives an unpredictable format, then I can't convert it into a C# DateTime object. Maybe there is another preferrable way to handle date times between the client and server? I don't even know why the Grid uses the American format as default because I work on a German workstation here.






  2. Viktor Tachev
    Viktor Tachev avatar
    1444 posts

    Posted 27 Jun Link to this post

    Hi Kaan,

    Please examine the following article that describes how you can have the same time format on the server and the client.

    Viktor Tachev
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET AJAX banner
Back to Top