Reputation: 196459
I have a DateTime object. How can I print just the time and in the following format:
5:50 PM
or
3:30 AM
Upvotes: 1
Views: 82
Reputation: 712
Try doing .ToShortTimeString() on your date object. For example:
DateTime.Now.ToShortTimeString();
Upvotes: 2
Reputation: 4892
DateTime dt = DateTime.Now;
Console.WriteLine(dt.ToString("h:mm tt", new System.Globalization.CultureInfo("en-us")));
try this
Upvotes: 2