skip to Main Content

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.

2

Answers


  1. DateTime.Now.ToString("MM/dd/yyyy hh:mm tt")
    Add tt at last for AM/PM

    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search