转换成  2011-12-18 06:59

解决方案 »

  1.   

     
    string str = "201112180659";
            if (str.Length >= 12)
            {
                string sNew = str.Substring(0, 4) + "-" + str.Substring(4, 2) + "-" + str.Substring(6, 2) + " " + str.Substring(8, 2) + ":" + str.Substring(10, 2);            DateTime date = Convert.ToDateTime(sNew);
            }
    sNew为“2011-12-18 06:59”字符串变量
    date为2011-12-18 06:59日期型变量
      

  2.   


    void Main()
    {
    Console.WriteLine(DateTime.ParseExact("201112180659","yyyyMMddHHmm",null).ToString("yyyy-MM-dd HH:mm"));
    //2011-12-18 06:59
    }