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

Timepicker 00:00-24:00

11 Answers 872 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Corey Alguire
Top achievements
Rank 1
Corey Alguire asked on 04 Jul 2008, 10:13 AM
I realize this may sound like a slightly strange question, but I was wondering if it is possible to show 00:00-24:00 in the TimePicker. At the moment, I cannot find anyway to include both 00:00 at the beginning and 24:00 at the end. I have a scenario where I need this for a client, and I was hoping to be able to accomplish it with the Rad TimePicker rather than the drop-down lists I inherited from the previous developer.

11 Answers, 1 is accepted

Sort by
0
Missing User
answered on 08 Jul 2008, 11:01 AM
Hi Corey Alguire,

The following code example demonstrates how to achieve your goal:

<%@ Page Language="C#" %> 
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"
    <title>Untitled Page</title> 
    <script runat="server"
        protected void Page_Load(object sender, EventArgs e) 
        { 
            RadTimePicker1.TimeView.StartTime = new TimeSpan(0, 0, 0, 0); 
            RadTimePicker1.TimeView.EndTime = new TimeSpan(1, 0, 0, 1); 
        }     
    </script> 
</head> 
<body> 
    <form id="form1" runat="server"
        <asp:ScriptManager ID="ScriptManager1" runat="server" /> 
        <div> 
            <telerik:RadTimePicker ID="RadTimePicker1" runat="server"
                <TimeView TimeFormat="HH:mm:ss"></TimeView> 
            </telerik:RadTimePicker> 
        </div> 
    </form> 
</body> 
</html> 
 


Best wishes,
Plamen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Mats
Top achievements
Rank 1
answered on 20 Nov 2009, 12:40 PM
Hi!

I have a need for my users to be able to type 00:00 to 24:00 into the input field.
Typing 24:00 really means 00:00 next day.

When I type 24:00 in the input field some validator is saying that it is not valid.

Is there a way to override this functionality?

Thanks
/Mats
0
Dimo
Telerik team
answered on 20 Nov 2009, 12:52 PM
Hi Mats,

Well, 24:00 is not really a valid time, so it is not supported, sorry.

I suggest you to make your users select 00:00 with the next day's date.

Best wishes,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Casey
Top achievements
Rank 1
answered on 24 Nov 2009, 07:59 PM
Hi Dimo,

I know that 24:00 is not a valid time and not supported, but would it be possible to check the value in the Date Input on some event (like Text Changed) and then switch from 24:00 to 00:00 of the next day with code?

Casey
0
Dimo
Telerik team
answered on 25 Nov 2009, 12:58 PM
Hello Casey,

Since you want to add a date information to the selected time, the more reasonable option is to use a RadDateTimePicker.

Alternatively, you can use the following approach. The important thing is to set a DateFormat for the DateInput control, which contains the date information. Otherwise the date information coming from the TimeView will be stripped and today's date will be applied in the end.


<%@ Page Language="C#" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
 
    <script runat="server">
         
        protected void Page_Load(object sender, EventArgs e)
        {
            DateTime[] dtArray = new DateTime[25];
            DateTime startTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);
            for (int hours = 0; hours < 25; hours++)
                dtArray[hours] = startTime.AddHours(hours);
             
            RadTimePicker1.TimeView.DataList.DataSource = dtArray;
        }
         
    </script>
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
 
<head id="Head1" runat="server">
    <title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
 
<telerik:RadTimePicker ID="RadTimePicker1" runat="server" Width="200px">
    <TimeView TimeFormat="HH:mm" />
    <DateInput DateFormat="yyyy/MM/dd HH:mm:ss" />
</telerik:RadTimePicker>
 
</form>
</body>
</html>



All the best,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Casey
Top achievements
Rank 1
answered on 27 Nov 2009, 12:14 PM
Hi Dimo,

In my question I mistakenly put Date Input when I really meant Time Input. My question goes along the same lines as Mats question though. Since he has a requirement to allow 00:00 through 24:00 (which is really 00:00 next day) to be entered into the Time Input, but the validator on the TimePicker control doesn't allow this, would it be possible to somehow cancel the validaton or force the validation to be ok? Or would it be possible in the TextChanged event of the TimeInput to implement logic to reset the time to 00:00 and change some flag that indicates whether or not 24:00 was entered?

Casey
0
Dimo
Telerik team
answered on 27 Nov 2009, 12:19 PM
Hello Casey,

We do not have a "TimeInput" control, what do you mean by that?

Also, did you test the simple example from my previous post? What is the difference between that example and your requirement?

Kind regards,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Casey
Top achievements
Rank 1
answered on 27 Nov 2009, 12:35 PM
Dimo,

What I meant by TimeInput is the input part of the RadTimePicker. I guess when I mentioned 'DateInput' in my first post that I had the correct name. I'm not asking a different question from Mats question. I'm just curious if there is a way  for Mats to achieve what he is asking by allowing the users to enter 24:00 into the Input section of the RadTimePicker without the control saying it is not valid.

Casey 
0
Dimo
Telerik team
answered on 27 Nov 2009, 01:10 PM
Hi Casey,

The TimePicker uses a DateInput as its textbox - it's just the name of the control. I am afraid that the DateInput will not accept 24:00 as a valid value under any circumstances and will not keep it.

Sincerely yours,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Rob
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 17 Aug 2016, 05:12 AM

Damn.. just what I also need..

I'm guessing no progress on this one so maybe I need to remove all my time pickers and find another solution :(

 

0
Eyup
Telerik team
answered on 19 Aug 2016, 07:04 AM
Hi Rob,

Perhaps setting custom values within the TimeView will prove helpful for this specific requirement:
http://docs.telerik.com/devtools/aspnet-ajax/controls/timepicker/functionality/configuring-the-embedded-time-view#radtimepicker-custom-values

Regards,
Eyup
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Calendar
Asked by
Corey Alguire
Top achievements
Rank 1
Answers by
Missing User
Mats
Top achievements
Rank 1
Dimo
Telerik team
Casey
Top achievements
Rank 1
Rob
Top achievements
Rank 2
Iron
Veteran
Iron
Eyup
Telerik team
Share this question
or