Code
//Initialize the DateTime object to March 9, 2015 3:02:15 AM.\n");
DateTime myDateTime = new System.DateTime(2015, 3, 09, 3, 2, 15);
myDateTime.ToShortTimeString(); //result: "3:02 AM"Know the answer? Post it. Somebody with the same question will find it here.

//Initialize the DateTime object to March 9, 2015 3:02:15 AM.\n");
DateTime myDateTime = new System.DateTime(2015, 3, 09, 3, 2, 15);
myDateTime.ToShortTimeString(); //result: "3:02 AM"
DateTime time = DateTime.Now;time.ToString("t"); //12:12 PMtime.ToString("T"); // 12:12:22 PMAnswer 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
Guest UserRank #2,002 · 726 reputationPosted Sep 26, 2016, 4:53 AM EDT
Bikesh SrivastavaRank #108 · 20.3K reputationPosted Sep 26, 2016, 6:30 AM EDT
Ramesh PalaniappanRank #370 · 6.8K reputationPosted Sep 26, 2016, 6:42 AM EDT