DateTime AM/PM format convert to 24h format
10,796
Date and times are not internally stored with any format in mind.
When you want to display the date/time, you use a format string on the ToString
method of the object. There are standard and custom format strings.
For 24 hours use:
string formatted24HourTime = myDateTime.ToString("HH:mm");
Related videos on Youtube
Author by
N.D
Updated on June 04, 2022Comments
-
N.D almost 2 years
i have a DateTime which is in AM/PM format . I want to convert it to 24h format , how can i do it? thanks.
-
Maurício about 13 yearsWhat language are you using? What have you tried so far?
-
-
N.D about 13 yearsthank you. I had a problem with getting the value from the DB but now it is ok, but if i want my datetime to be formated like YYYYMMDDHHmmss ? is there a format like this?
-
Oded about 13 years@olia - I linked to both the standard and custom documents on MSDN. I suggest looking there.