fork download
  1. using System;
  2. using System.Globalization;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string data1 = "01/08/2016 9:00 AM";
  9. string data2 = "01/08/2016 9:00 PM";
  10.  
  11. DateTime dataOut;
  12.  
  13. if(DateTime.TryParse(data1, out dataOut))
  14. {
  15. Console.WriteLine(dataOut.ToString("HH:mm ", CultureInfo.InvariantCulture));
  16. }
  17.  
  18. if(DateTime.TryParse(data2, out dataOut))
  19. {
  20. Console.WriteLine(dataOut.ToString("HH:mm ", CultureInfo.InvariantCulture));
  21. }
  22. }
  23. }
Success #stdin #stdout 0.02s 29944KB
stdin
Standard input is empty
stdout
09:00 
21:00