string[] DateTimeList = { "yyyy/M/d tt hh:mm:ss", "yyyy/MM/dd tt hh:mm:ss", "yyyy/MM/dd HH:mm:ss", "yyyy/M/d HH:mm:ss", "yyyy/M/d", "yyyy/MM/dd" }; DateTime dt = DateTime.ParseExact(" 2014/ 8/16 PM 03: 20:50 ", DateTimeList, CultureInfo.InvariantCulture, DateTimeStyles.AllowWhiteSpaces );