Code here :-
string CurrentTime = String.Format("{00:t}", DateTime.Now);
OutPut Something like this :- 9:45 AM
how can get time value something like this :- 09:45 AM
Code
please let me know how to get this Time format :- 09:45 AMplease let me know how to get this Time format :- 09:45 AMKnow the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Shakti Singh DulawatRank #668 · 3.6K reputationPosted Apr 26, 2016, 5:44 AM EDT
DateTime.ToString() Patterns
All the patterns:
The patterns for DateTime.ToString ( 'd' ) :
The patterns for DateTime.ToString ( 'D' ) :
The patterns for DateTime.ToString ( 'f' ) :
The patterns for DateTime.ToString ( 'F' ) :
The patterns for DateTime.ToString ( 'g' ) :
The patterns for DateTime.ToString ( 'G' ) :
The patterns for DateTime.ToString ( 'm' ) :
The patterns for DateTime.ToString ( 'r' ) :
The patterns for DateTime.ToString ( 's' ) :
The patterns for DateTime.ToString ( 'u' ) :
The patterns for DateTime.ToString ( 'U' ) :
The patterns for DateTime.ToString ( 'y' ) :
Building a custom DateTime.ToString Patterns
The following details the meaning of each pattern character. Note the K and z character.
||\c || Represents the escape character, and displays the character "c" as a literal when that character is preceded by the escape character (\). To insert the backslash character itself in the result string, the application should use two escape characters ("\\").
Any other character copies any other character to the result string, without affecting formatting. ||