string d1="2005-10-1 12:12:12";
    DateTime dt1=DateTime.Parse(d1);
    string d2="20051001121212";
    DateTime dt2=DateTime.ParseExact(d2,"yyyyMMddHHmmss",System.Globalization.DateTimeFormatInfo.CurrentInfo);
    Console.WriteLine(d1 + "\t" + dt1.ToString());
    Console.WriteLine(d2 + "\t" + dt2.ToString());

DateTime dt2=DateTime.ParseExact()
可以定义任何形式的时间格式;

相关文章:

  • 2021-12-13
  • 2021-11-26
  • 2021-09-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-09
  • 2022-12-23
猜你喜欢
  • 2022-02-28
  • 2021-06-18
  • 2022-12-23
  • 2022-01-30
  • 2022-12-23
相关资源
相似解决方案