Get DateTime from RadDatePicker and RadTimePicker

5 posts, 0 answers
  1. Jiju
    Jiju avatar
    56 posts
    Member since:
    Jul 2011

    Posted 08 Sep 2012 Link to this post

    Hi,
    how to get the datetime value using javascript by combining the values of RadDatePicker and RadTimePicker

    thanks in advance
    Jiju

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 10 Sep 2012 Link to this post

    Hi,

    Try the following javascript.
    JS:

    function OnClientClick()
       {
           var datePicker = $find("<%=RadDatePicker1.ClientID %>");
           var timepicker = $find("<%=RadTimePicker1.ClientID %>");
           var dt = datePicker.get_dateInput().get_selectedDate().format("yyyy/MM/dd");
           var time = timepicker.get_dateInput().get_value();
           alert(dt +" "+ time);
       }

    Thanks,
    Princy.

  3. DevCraft Release
  4. Jiju
    Jiju avatar
    56 posts
    Member since:
    Jul 2011

    Posted 13 May 2013 Link to this post

    hi, 
    how can i get the datetime to a variable ?
    I tried the below code but not working.

    var selectedDate = new Date(datePicker.get_dateInput().get_selectedDate() + " " + timepicker.get_dateInput().get_value());
    it returns null value.

    thanks in advance

    regards
    Jiju

  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 13 May 2013 Link to this post

    Hi Jiju,

    Please have a look at the following code I tried which works fine at my end.

    ASPX:

    <telerik:RadDatePicker ID="RadDatePicker1" runat="server">
    </telerik:RadDatePicker>
    <telerik:RadTimePicker ID="RadTimePicker1" runat="server">
    </telerik:RadTimePicker>
    <br />
    <br />
    <telerik:RadButton ID="RadButton1" runat="server" AutoPostBack="false" Text="Get Date and Time" OnClientClicked="OnClientClicked">
    </telerik:RadButton>

    JavaScript:
    <script type="text/javascript">
        function OnClientClicked(sender, args) {
            var datePicker = $find("<%=RadDatePicker1.ClientID %>");
            var timepicker = $find("<%=RadTimePicker1.ClientID %>");
            var selectedDate = datePicker.get_selectedDate().format("yyyy/MM/dd");
            var selectedTime = timepicker.get_selectedDate().format("HH:mm:ss")
            alert(selectedDate + " " + selectedTime);
        }
    </script>

    Thanks,
    Shinu.

  6. Mayur
    Mayur avatar
    12 posts
    Member since:
    Oct 2013

    Posted 07 Nov 2013 Link to this post

    Thanks Princy,
                            Your blog really helped me to resolve a big issue in my project. I would be always thankful to you.

Back to Top
DevCraft Release