Datasource date format incompatibile with ASP.NET MVC date format

4 posts, 0 answers
  1. martonx
    martonx avatar
    7 posts
    Member since:
    Nov 2010

    Posted 01 Aug 2012 Link to this post

    Hi,

    This is a strange problem. I have a grid with dates from ASP.NET MVC. In the grid the dates are look OK.
    I'm using "hu-HU" globalization.
    When I update, or create a row, the sended date is this format: Wed Aug 1 17:32:58 UTC+0200 2012
    This looks like in httpencoding in GET: projects%5B0%5D.start=Wed+Aug+01+2012+00%3A00%3A00+GMT%2B0200+(K%C3%B6z%C3%A9p-eur%C3%B3pai+ny%C3%A1ri+id%C5%91) 
    And here it is my MVC controller action:
    public JsonResult CreateProject(IEnumerable<ProjectViewModel> projects){...}

    When I check projects I see that date's parsed failed so I see my Datetimes in my incoming object: {0001.01.01. 0:00:00}

    Please advice, what should I do for good date communication protocol?

    Thank you very much!
  2. Sig
    Sig avatar
    8 posts
    Member since:
    Mar 2011

    Posted 09 Sep 2012 Link to this post

    I'm having a very similar issue.

    When I post form data back from a Kendo control (in this case a date-picker), it's posts the date as follows:
    Tue Sep 04 2012 00:00:00 GMT-0700 (Pacific Daylight Time)

    The issue I have is that I want it to post in a different format.... the above format is not readily parse-able for asp.net mvc when model-binding.  Is there a good workaround to grab the date and modify it prior to posting the data on a form-submit?

    Thanks!
  3. Kendo UI is VS 2017 Ready
  4. Sig
    Sig avatar
    8 posts
    Member since:
    Mar 2011

    Posted 09 Sep 2012 Link to this post

    Ok, I think I found the issue I was having...

    When posting data, it looks like IE vs. Firefox vs. Chrome all behave slightly differently. 
    Below are the possibilities of dates in various browsers:
    IE 10: "Tue Sep 4 00:00:00 PDT 2012"
    Firefox 15:01: "Tue Sep 04 2012 00:00:00 GMT-0700 (Pacific Daylight Time)"
    Chrome 21.0.1180.89: "Tue Sep 04 2012 00:00:00 GMT-0700 (Pacific Daylight Time)"

    That would explain why I can parse dates in IE, but not in Firefox and chrome (asp.net mvc doesn't understand dates with the appeneded "Pacific Daylight Time". 

    My option is to trim a string to not contain anything from the first location of a parentheses on, and that seems to solve the issue, but there has to be a way to tell Kendo what format to pass dates in, right?

    Anyone have any thoughts on this?
  5. Sig
    Sig avatar
    8 posts
    Member since:
    Mar 2011

    Posted 09 Sep 2012 Link to this post

    Good stack overflow article for MartinX and anyone else reading this thread:
    http://stackoverflow.com/questions/10197437/how-to-convert-string-to-date-time
Back to Top
Kendo UI is VS 2017 Ready