I want to convert and restrict the DateTime to 12 hours format. Right now the output is : 02-01-2022 18:30 PM but I want to convert into 02/01/2022 06:30 PM 00:00.
CodePudding user response:
DateTime.Now.ToString("MM/dd/yyyy hh:mm tt")
Add tt at last for AM/PM
CodePudding user response:
string CustomDateFormat = DateTime.Now.ToString("MM/dd/yyyy hh:mm tt 00:00");
or
string CustomDateFormat = DateTime.Now.ToString("MM/dd/yyyy hh:mm tt") " 00:00";
where hh is for 12 hours format and tt for AM/PM as in this documentation.
