KendoDatePicker : JSON.stringify function for kendoDatePicker value is giving wrong date

2 posts, 0 answers
  1. Ambica
    Ambica avatar
    6 posts
    Member since:
    Dec 2012

    Posted 08 Mar 2013 Link to this post

    Hi ,
    In my scenario, have to call web service with StartDate of string type  (POST operation), 
    am using JSON. Stringify method to convert data into json format .

    My problem is while stringifying my data , date is going back by one day.

    code:
        var tStartDate = $("[Name=StartDate]").data("kendoDatePicker").value()
                value is : Mon Mar 04 2013 00:00:00 GMT+0530 (India Standard Time) (here time 00:00:00)

        JSON.stringify(tStartDate)
                         This giving :  2013-03-03T18:30:00.000Z instead of 2013-03-04T18:30:00.000Z
    So how can I get correct Date here ? in our DB using DateTimeOffset type for storing this date value 

    Please help me out .



  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3747 posts

    Posted 12 Mar 2013 Link to this post

    Hello Ambica,

    The described behavior is actually expected. The kendo.stringify, like the native JSON.stringify serializes dates using UTC time. Hence the shown date without five and a half hours is previous day. Check this jsBin demo for more information. If you want to change this behavior you will need to specify a parameterMap function and serialize Date objects manually.

    Regards,
    Georgi Krustev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top