How to display (date & Time 24hr format)

2 posts, 0 answers
  1. salvio
    salvio avatar
    17 posts
    Member since:
    Oct 2010

    Posted 24 Feb 2011 Link to this post

    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">
                    <telerik:TargetInput ControlID="txt_date2"  />

    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...

  2. Tsvetina
    Tsvetina avatar
    2481 posts

    Posted 01 Mar 2011 Link to this post

    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" "">
        <title>Untitled Page</title>
        <form runat="server">
        <script runat="server">
            protected void Button1_Click(object sender, EventArgs e)
                txt_date2.Text = DateTime.Now.ToString();
        <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">
                    <telerik:TargetInput ControlID="txt_date2" />
        <asp:Button ID="Button1" runat="server" Text="Set Time" OnClick="Button1_Click" />

    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,
    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!
Back to Top