Click here to Skip to main content
15,903,012 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Updated 2-Dec-10 22:21pm
v2
Comments
Dalek Dave 3-Dec-10 4:21am    
Edited for Grammar, Spelling and Readability.

1 solution

Here are a couple ways to show AM and PM with your time:

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


2. Use a custom format [^] to specify a 12-hour time:
C#
toolstriplabel1.Text = DateTime.Now.ToString("hh:mm tt");
 
Share this answer
 
v2
Comments
narendra999 2-Dec-10 23:27pm    
if we add "hh:mm tt" we will get am and pm appended to time
JOAT-MON 3-Dec-10 4:00am    
Right, good catch! Sorry I missed that when I typed it in.
Dalek Dave 3-Dec-10 4:21am    
Good Call.

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