Click here to Skip to main content
15,905,614 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Dear Friends,

How to display time in 24 hours format.

This is my code, this is displaying in 12 hours format.

C#
SqlCommand cmd = new SqlCommand();
        cmd.Connection = con;
        cmd.CommandText = "Select Timelupdate from TimeLastUpdate";
        using (con)
        {
            con.Open();
            SqlDataReader reader = cmd.ExecuteReader();

            if (reader.Read())
            {
                lblUpdate.Text = DateTime.Parse(reader["Timelupdate "].ToString()).ToString("dd/MM/yyyy hh:mm tt");

                lblUpdate.ForeColor = Color.Red;
                lblUpdate.Visible = true;
            }
        }


I need 24 hrs format....please help.

Thanks in advance
Posted
Updated 9-Nov-12 23:15pm
v2

Try capital HH in your format string
 
Share this answer
 
Comments
Ranjith Reddy CSE 10-Nov-12 5:10am    
Thank you so much....
HH      display two-digit hours on 24-hour scale

Format string pattern

MMM     display three-letter month
ddd     display three-letter day of the WEEK
d       display day of the MONTH
HH      display two-digit hours on 24-hour scale
mm      display two-digit minutes
yyyy    display four-digit year
 
Share this answer
 
Comments
Ranjith Reddy CSE 10-Nov-12 5:03am    
Thank you so much....
Shanalal Kasim 10-Nov-12 5:07am    
welcome
try For HH in hour minute second
 
Share this answer
 
Comments
Ranjith Reddy CSE 10-Nov-12 5:03am    
Thank you so much....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900