>DateTime dt; > >if (DateTime.TryParse("10:30 AM", out dt)) >{ > Console.WriteLine (dt.Hour); > Console.WriteLine(dt.Minute); > ? Console.WriteLine(dt.); >}Either one of these should do the trick:
Console.WriteLine( dt.ToString("t")); Console.WriteLine( dt.ToString("hh:mm tt"));Using format strings has the additional advantage that they are locale aware - if you run this on a machine in Germany you get the local German format (which would be 24 hour clock instead of AM/PM).