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

Start time in datetimepicker

3 Answers 152 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 2
Steve asked on 07 Sep 2012, 10:30 PM
Hi everybody !

I would like to know how to setup the starttime in a datetimepicker codebehind ?

Thanks in advance.

Steve.

3 Answers, 1 is accepted

Sort by
0
Accepted
Vasil
Telerik team
answered on 12 Sep 2012, 11:11 AM
Hi Steve,

If your picker is declared like:
<telerik:RadDateTimePicker runat="server" ID="picker1"></telerik:RadDateTimePicker>

You can set MinDate in the code behind using this line of code:
picker1.MinDate = new DateTime(2010,5,14,11,12,13);
This will be 14 of May 2012 year,  11AM, 12 minutes and 13 seconds.

Greetings,
Vasil
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Accepted
Aarsh
Top achievements
Rank 1
answered on 12 Sep 2012, 04:51 PM
Hi, Steve

I can suggest alternative as below :


RadDateTimePicker.TimeView.StartTime = <Some Time Span Here>;

Time Span it self has several overlaods...

  1. You can use already existing time span object
  2. passing (long) ticks
  3. (int) hrs, (int) min, (int) seconds(int)
  4. (int) days, (int) hrs, (int) min, (int) seconds  -  Where days is # of dats
  5. (int) days, (int) hrs, (int) min, (int) seconds, (int) millisecond


if you've it in the dateTime format, you amy try the following for cast to timeSpan type

string s = "4:15 PM";
DateTime t = DateTime.ParseExact(s, "H:mm tt", CultureInfo.InvariantCulture);
// This will get the time elapsed since midnight.
TimeSpan ts = t.TimeOfDay;


I hope this helps you a bit, let me know if you need further guidance.

Thanks,
-Aarsh

0
Steve
Top achievements
Rank 2
answered on 12 Sep 2012, 04:59 PM
Thanks for your help, in this case both solutions works perfect !!!

Steve
Tags
General Discussions
Asked by
Steve
Top achievements
Rank 2
Answers by
Vasil
Telerik team
Aarsh
Top achievements
Rank 1
Steve
Top achievements
Rank 2
Share this question
or