Date/Time Format

G

Guest

I am trying to figure out how to display "AM" or "PM" for the time? The book I am looking at shows "aa", but that does not work. This also means that I do not want to show time in a 24 hour format, but with a 12 hour format with am/pm indicator. How do you do this is in the .Net world

Thanks in advance for your assistance.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi Jim,

Take a look at DateTime.ToString() , you can format a DateTime as needed,
IIRC using this
DateTime.Now.ToString( "h:mm tt" , DateTimeFormatInfo.InvariantInfo )

Will do the trick. But I did not test it, I wrote it from memory so test it
before !!!

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

jim Heavey said:
I am trying to figure out how to display "AM" or "PM" for the time? The
book I am looking at shows "aa", but that does not work. This also means
that I do not want to show time in a 24 hour format, but with a 12 hour
format with am/pm indicator. How do you do this is in the .Net world?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top