RadDatePicker setting Date in German Format

5 posts, 1 answers
  1. Deva Kumar
    Deva Kumar avatar
    12 posts
    Member since:
    Nov 2009

    Posted 24 Nov 2009 Link to this post

    Dear Experts,

    I have a issue on setting the RadDatePicker Date using set_selectedDate client side method.
    I have also set the culture of the RadDatePicker contrl.

    I am able to perform this - Culture - en-US

            rdpicker.set_selectedDate(

    new Date('05/01/2009'));

    But I am unable to perform this - Culture - de-DE
            rdpicker.set_selectedDate(new Date('05.01.2009'));

    I guess this could be the problem on date format in client side.

    Could you please help me on this?

    Thank you,
    Deva

     

  2. Daniel
    Admin
    Daniel avatar
    4949 posts

    Posted 24 Nov 2009 Link to this post

    Hello Deva,

    The Date object is part of JavaScript language and not a Telerik's client-side method. Please examine the following links for more information:
    http://www.w3schools.com/js/js_obj_date.asp
    http://www.devguru.com/technologies/ecmascript/QuickRef/date.html
    http://www.prism.washington.edu/lc/CLWEBCLB/jst/js_datetime.html
    http://www.tizag.com/javascriptT/javascriptdate.php

    Regards,
    Daniel
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Deva Kumar
    Deva Kumar avatar
    12 posts
    Member since:
    Nov 2009

    Posted 24 Nov 2009 Link to this post

    Thanks for your kind support Daniel. I understood that

    Can I pass a date like this "2008-12-04T05:00:00Z" to the Date parameter of this function.???

    rdpicker.set_selectedDate(new Date('2008-12-04T05:00:00Z'));

    I feel like - by doing this - I can avoid the German/English culture problems and just set the culture property of RADDATEPICKER alone.

    Thank you,
    Deva
  4. Answer
    Daniel
    Admin
    Daniel avatar
    4949 posts

    Posted 24 Nov 2009 Link to this post

    Hello Deva,

    RadDatePicker's set_selectedDate property accepts JavaScript Date object as parameter. If you pass the date in the mentioned notation you will probably receive an "Invalid Date" error.

    You should construct the date in a similar manner:
    <script type="text/javascript">
        var stringDate = '2008-12-04T05:00:00Z';
        var dPart = stringDate.split("T")[0].split("-");
        var tPart = stringDate.split("T")[1].split(":");
        var dateObject = new Date(dPart[0], dPart[1] - 1, dPart[2], tPart[0], tPart[1], tPart[2].split("Z")[0], 0);
        alert(stringDate + "\n" + dateObject);
    </script>

    Regards,
    Daniel
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Deva Kumar
    Deva Kumar avatar
    12 posts
    Member since:
    Nov 2009

    Posted 24 Nov 2009 Link to this post

    Thanks a lot Daniel. :)

    The solution provided by you is simply superb. Thanks again.

    The problem is solved for me.

    Thank you,
    Deva
Back to Top