Set value RadDateTimePicker with javascript

6 posts, 0 answers
  1. Minh
    Minh avatar
    13 posts
    Member since:
    Jan 2010

    Posted 02 Feb 2010 Link to this post

    Dir sir,
    I want set value RadateTimePicker with javascript:

     

    var

     

    radStartTime = $find("<%= RadDateTime_BD.ClientID %>")

    radStartTime.set_selectedDate(

    "2010,2,2,8,30,0");

    But not working,
    Can you help me?
    Thanks for support,
    Brgs,

     

  2. Daniel
    Admin
    Daniel avatar
    4949 posts

    Posted 02 Feb 2010 Link to this post

    Hello Hoc,

    Please note that set_selectedDate property accepts Date object.
    radStartTime.set_selectedDate(new Date(year, month, day, hours, minutes, seconds, milliseconds));

    For more information about the Date object, please examine the following link:
    JavaScript Date Object

    Best regards,
    Daniel
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  3. Minh
    Minh avatar
    13 posts
    Member since:
    Jan 2010

    Posted 03 Feb 2010 Link to this post

    Dir Daniel,
    If
    radStartTime.set_selectedDate(new Date(MM/dd/yyyy hh:mm));
    is ok?
    Thanks for support,
    Brgs,

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

    Posted 03 Feb 2010 Link to this post

    Hello,

    If you want to set the DateFormat from client side, then use the following client side code.

    client side code:
     
       var datetimePicker = $find("<%=RadDateTimePicker2.ClientID%>"); 
       datetimePicker.get_dateInput().set_dateFormat("MM/dd/yyyy"); 
       datetimePicker.get_dateInput().set_displayDateFormat("MM/dd/yyyy"); 
          
    Also checkout the documentation: RadDateTimePicker Client Object . I hope you will find this as useful.

    -Shinu.
  5. Daniel
    Admin
    Daniel avatar
    4949 posts

    Posted 03 Feb 2010 Link to this post

    Hello Hoc,

    As explained in W3Schools there are four ways to instantiate a Date object:

    new Date() // current date and time

    new Date(milliseconds) //milliseconds since 1970/01/01
    new Date(dateString)
    new Date(year, month, day, hours, minutes, seconds, milliseconds)

    Note that most of the parameters are optional - for example, if you pass the date part only, the next four parameters (time) will be set to 0 (default value).

    Regards,
    Daniel
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  6. Roshil
    Roshil avatar
    29 posts
    Member since:
    Jun 2011

    Posted 23 Jul 2011 Link to this post

    Hi Daniel,

       I have the following script
           

    function DateSelectedFirstPref(sender, args) {         

                     if (!isTimeSelected) {

                         var val = "08:00:00";

                         var dateString = sender._dateInput._initialValue;

                         var month = dateString.split("/")[0];

                         var day = dateString.split("/")[1];

                         var yearTime = dateString.split("/")[2];

                         var year = yearTime.split(" ")[0];            

                          sender.set_selectedDate(new Date(year, month, day, val.split(":")[0], val.split(":")[1], val.split(":")[2], 0));                      

                    

                     }

                }


    When i select a date from datetime picker, it is not showing any date and time,the raddatetime picker's textbox is empty.
    Please help me on this issue.
Back to Top