Click here to Skip to main content
15,847,902 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to show UTC date time in 24 hour format in c#. Currently I am getting the time format in 12 hour format only. I want to show the same in 24 hour format

What I have tried:

Code is as below:
DateTime dt = DateTime.Now.ToUniversalTime();
strCreatedDate = dt.ToString("yyyy-MM-ddThh:mm:ss.fffZ");
Updated 13-Sep-22 0:07am

Share this answer
try this
string strCreatedDate;
strCreatedDate = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss");
Share this answer

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