1

I have one raddatetimepicker in my page. I am getting one date as string like this in javascript "2014-06-03T23-00-00Z"

I want to set this date to my raddatetimepicker.

I tried using this Set the date to raddatepicker by using Javascript

But it is not working.

I also tried like this

var myDate = "2014-06-03T23-00-00Z";
var cdate = myDate.replace('T', ' ').replace('Z', '');
$find("<%= fromDate.ClientID %>").set_selectedDate(dt);
Community
  • 1
  • 1
vaibhav shah
  • 4,939
  • 19
  • 58
  • 96
  • I hope my answer helped. Is this Telerik for ASP.NET or MVC? You should tag the question accordingly to help people find this. Happy coding! – DanM7 Jun 25 '14 at 15:02

1 Answers1

1

The function set_selectedDate accepts a JavaScript Date object. Try the example below that also converts your current format to the valid Date object:

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
        function setDate() {
            var dt = "2014-06-20T23-00-00Z";
            dt = dt.replace('T', '-').replace('Z', '');
            var ar = dt.split('-');
            var rdtp1 = $find('<%= rdtp1.ClientID %>');
            rdtp1.set_selectedDate(new Date(ar[0], ar[1]-1, ar[2], ar[3], ar[4], ar[5]));
        }
    </script>
</telerik:RadCodeBlock>

<telerik:RadDateTimePicker ID="rdtp1" runat="server">
</telerik:RadDateTimePicker>

<asp:Button ID="btnR" runat="server" OnClientClick="setDate(); return false;" />

Take a look at this question for more info on converting strings to the Date object in JavaScript.

Community
  • 1
  • 1
DanM7
  • 2,203
  • 3
  • 28
  • 46