一系列数值转DataTime

string strDT = "20130228223022";
            string strDTTem = string.Format("{0}/{1}/{2}  {3}:{4}:{5}",
                                             strDT.Substring(0, 4), strDT.Substring(4, 2),
                                             strDT.Substring(6, 2), strDT.Substring(8, 2),
                                             strDT.Substring(10, 2), strDT.Substring(12, 2)
                                           );   
            DateTime dt = DateTime.Parse(strDTTem);
           
           // DateTime dt = DateTime.Parse("2013-5-29  11:54:30");
           // Console.WriteLine(dt.ToString());输出2013/5/29 11:54:30

            Console.WriteLine(dt.ToString());

posted @ 2013-05-30 21:43  Predator  阅读(110)  评论(0编辑  收藏  举报