将AM和PM附加到用于时间控制的标签上

问题描述:

早安,

我有一个带有工具条标签的状态栏.

我正在努力在页面底部显示时间,这已经完成了.
我的问题是根据时间显示上午和下午.

Windows应用程序,C#.

希望您了解了.

请回复

--- Narendra

Hi GoodMorning,

I have a statusbar which has toolstriplabels.

I am working to show time at bottom of my page, which I have done.
My problem is to show AM and PM based on time.

Windows applications,C#.

Hope you Understood.

Please reply

---Narendra

以下是显示时间的AM和PM的几种方法:

1.使用LongTime格式:
Here are a couple ways to show AM and PM with your time:

1. Use the LongTime format:
toolstriplabel1.Text = DateTime.Now.ToLongTimeString();



2.使用自定义格式 [



2. Use a custom format [^] to specify a 12-hour time:

toolstriplabel1.Text = DateTime.Now.ToString("hh:mm tt");