Is there a slick way to convert simple numbers (Army time included) to a time format (am, pm format)? I can do the tedious approach, but I was just wondering if there was another way
0800 => 8:00 am
2317 => 11:17 pm
DateTime dt = DateTime.ParseExact("0800", "HHmm", CultureInfo.InvariantCulture);
string timestring = dt.ToString("h:mm tt");
See documentation for format codes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With