C # Output 24-hour format time

Source: Internet
Author: User

When I was testing a program, I found that it was supposed to be 24, and it turned out to be 12 hours, so the order was incorrect when the list was loaded.

Then it should be time. The format problem of ToString (xx) xx.

So you need this:

such as MessageBox.Show (DateTime.Now.ToString ("Yyyy-mm-dd hh:mm:ss"));

Will output 2014-4-3 5:08:4 "12-hour format"

Then MessageBox.Show (DateTime.Now.ToString ("Yyyy-mm-dd HH:mm:ss"));

Will output 2014-4-3 17:08:4 "24-hour format"

So here's what to note:

YYYY-MM-DD is a fixed notation for 2014-04-03 here to use mm (month) instead of MM (for minutes)

We also wish to note that:

C # Output 24-hour format time

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.