如何以24小时格式显示时间 [英] How to display time in 24 hours format

查看:206
本文介绍了如何以24小时格式显示时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的朋友,

如何以24小时格式显示时间.

这是我的代码,以12小时格式显示.

Dear Friends,

How to display time in 24 hours format.

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

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;
            }
        }



我需要24小时格式....请帮助.

在此先感谢



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

Thanks in advance

推荐答案

尝试使用格式字符串中的大写HH
Try capital HH in your format string


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


尝试以时分秒为单位的HH
try For HH in hour minute second


这篇关于如何以24小时格式显示时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆