This is a migrated thread and some comments may be shown as answers.

RadDatePicker setting Date in German Format

4 Answers 128 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Deva Kumar
Top achievements
Rank 1
Deva Kumar asked on 24 Nov 2009, 11:30 AM
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

 

4 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 24 Nov 2009, 01:33 PM
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.
0
Deva Kumar
Top achievements
Rank 1
answered on 24 Nov 2009, 01:45 PM
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
0
Accepted
Daniel
Telerik team
answered on 24 Nov 2009, 02:59 PM
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.
0
Deva Kumar
Top achievements
Rank 1
answered on 24 Nov 2009, 04:25 PM
Thanks a lot Daniel. :)

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

The problem is solved for me.

Thank you,
Deva
Tags
Calendar
Asked by
Deva Kumar
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Deva Kumar
Top achievements
Rank 1
Share this question
or