Force 24 hours datetime format

  • Thread starter Thread starter hvj
  • Start date Start date
H

hvj

Hi,

I am using DateTime.Now.ToString("yyyyMMddThhmmss"), but time is
displayed in 12-hours format. How can I force .NET to display 24 hours
format? Can I do something with the CultureInfo of the current thread.
I do not want it to be dependent of the settings of the computer.

Any help appreciated.

Regards,
Henk
 
Hi,

I am using DateTime.Now.ToString("yyyyMMddThhmmss"), but time is
displayed in 12-hours format. How can I force .NET to display 24 hours
format? Can I do something with the CultureInfo of the current thread. I
do not want it to be dependent of the settings of the computer.


use HH instead of hh
 
I am using DateTime.Now.ToString("yyyyMMddThhmmss"), but time is

Also, if you're trying to format to ISO 8601 (I assume this because of
the 'T' separator), the format you're using is incorrect. Correct format
is for exampple:

1997-07-16T19:20:30

you can also use XmlConvert.ToString(dateTime,
XmlDateTimeSerializationMode.XXX);

to format to ISO 8601

Ben
 

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

Back
Top