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

Set value RadDateTimePicker with javascript

5 Answers 483 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Minh
Top achievements
Rank 1
Minh asked on 02 Feb 2010, 04:09 PM

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,

 

5 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 02 Feb 2010, 06:13 PM
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.
0
Minh
Top achievements
Rank 1
answered on 03 Feb 2010, 06:14 AM
Dir Daniel,
If
radStartTime.set_selectedDate(new Date(MM/dd/yyyy hh:mm));
is ok?
Thanks for support,
Brgs,

0
Shinu
Top achievements
Rank 2
answered on 03 Feb 2010, 12:46 PM
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.
0
Daniel
Telerik team
answered on 03 Feb 2010, 01:07 PM
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.
0
Roshil
Top achievements
Rank 1
answered on 23 Jul 2011, 07:35 AM
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.
Tags
Calendar
Asked by
Minh
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Minh
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Roshil
Top achievements
Rank 1
Share this question
or