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

How to display (date & Time 24hr format)

1 Answer 981 Views
Input
This is a migrated thread and some comments may be shown as answers.
salvio
Top achievements
Rank 1
salvio asked on 24 Feb 2011, 03:33 PM
Hi All,

I tried the below code to display the date and time(24 hrs)... the time part not working wht i need..

<asp:TextBox ID="txt_date2" runat="server"></asp:TextBox>
<telerik:RadInputManager ID="RadInputManager1" runat="server">
  <telerik:DateInputSetting BehaviorID="DateInputBehavior3"  DateFormat="dd/MM/yyyy HH:mm">
             
            <TargetControls>
                <telerik:TargetInput ControlID="txt_date2"  />
            </TargetControls>
        </telerik:DateInputSetting>
 
</telerik:RadInputManager>

I want like, suppose the user type 24 in txtbox, on tab out automatically the txtbox should display  '24/02/2011 19:55"
the time should be also take in 24hs format ....Please give me solution to do this task...

Thanks

1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 01 Mar 2011, 03:13 PM
Hi Salvio,

I tested your code and it worked as expected - the time can be set to be anywhere between 00:00 and 23:59. Here is the full mark-up of the page that I used for testing:
<%@ 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">
<head>
    <title>Untitled Page</title>
</head>
<body>
    <form runat="server">
    <script runat="server">
        protected void Button1_Click(object sender, EventArgs e)
        {
            txt_date2.Text = DateTime.Now.ToString();
        }
    </script>
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
    <asp:TextBox ID="txt_date2" runat="server"></asp:TextBox>
    <telerik:RadInputManager ID="RadInputManager1" runat="server">
        <telerik:DateInputSetting BehaviorID="DateInputBehavior3" DateFormat="dd/MM/yyyy HH:mm">
            <TargetControls>
                <telerik:TargetInput ControlID="txt_date2" />
            </TargetControls>
        </telerik:DateInputSetting>
    </telerik:RadInputManager>
    <asp:Button ID="Button1" runat="server" Text="Set Time" OnClick="Button1_Click" />
    </form>
</body>
</html>

Please, keep in mind that writing only 24 in the textbox sets the date to the 24th of the current month but does not set a specific time value, so in my case it was the default 00:00 but it allowed to be changed to 16:00 for example.

All the best,
Tsvetina
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
Input
Asked by
salvio
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or