DateTime.ToString get specific time format

  • Thread starter Thread starter Grant Merwitz
  • Start date Start date
G

Grant Merwitz

Hi,

I'm trying to enter the time in the following format:
HH:MM:SS AM/PM

e.g. 05:33:21 PM

How can i achieve this from the Date Time object?

DateTime.Now.ToString("?");

I've search MSDN, and they only seem to cater for the 24 hour clock,
not the 12 hour clock

In the meanwhile, i strip the date by using DateTime.Now.Hour.
and then based on if it's greater than 12.

There must be a simpler built in way

TIA
 
Hi,

I'm trying to enter the time in the following format:
HH:MM:SS AM/PM

e.g. 05:33:21 PM

How can i achieve this from the Date Time object?

DateTime.Now.ToString("?");

I've search MSDN, and they only seem to cater for the 24 hour clock,
not the 12 hour clock

In the meanwhile, i strip the date by using DateTime.Now.Hour.
and then based on if it's greater than 12.

There must be a simpler built in way

TIA

DateTime.Now.ToString("hh:mm tt")
 
Back
Top