Start time in datetimepicker

4 posts, 2 answers
  1. Steve
    Steve avatar
    5 posts
    Member since:
    Aug 2012

    Posted 07 Sep 2012 Link to this post

    Hi everybody !

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

    Thanks in advance.

    Steve.
  2. Answer
    Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 12 Sep 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Aarsh
    Aarsh avatar
    192 posts
    Member since:
    Jun 2012

    Posted 12 Sep 2012 Link to this post

    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

  5. Steve
    Steve avatar
    5 posts
    Member since:
    Aug 2012

    Posted 12 Sep 2012 Link to this post

    Thanks for your help, in this case both solutions works perfect !!!

    Steve
Back to Top