Sending dates to server as yyyy-MM-dd

2 posts, 0 answers
  1. Alan Mosley
    Alan Mosley avatar
    200 posts
    Member since:
    Apr 2010

    Posted 19 Jan 2015 Link to this post

    Using date pickers I need to format as dd-MM-yyyy, but when posting to server I need to post as yyyy-MM-dd
    using ajax I can do this using "FromDate": kendo.toString($("#FromDate").data("kendoDatePicker").value(), "yyyy/MM/dd")

    but when using the MVC wrappers in a form how can I send to server as yyy-MM-dd?

    Thnaks
  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 21 Jan 2015 Link to this post

    Hello Alan,

    If you are posting the value to the server using regular Html form element, it is not possible to change format of the value without manual input value update on form submit. In other words, you will need to wire the submit event of the form and modify the value using the desired format. In general, this is not related to Kendo UI, but more to the way how the successful controls work in Html.

    If you are posting the values using Ajax, you can update posted value before sending it to the server, as you mentioned in your message. Again the change should be done manually.

    The third possible way to support such value format differences is to use custom ModelBinder that will know how to parse date strings with different formats.

    Regards,
    Georgi Krustev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top