Converting a String to DateTime

后端 未结 17 2577
南方客
南方客 2020-11-21 06:12

How do you convert a string such as 2009-05-08 14:40:52,531 into a DateTime?

17条回答
  •  盖世英雄少女心
    2020-11-21 06:50

    string txtDate="15-06-2020";  //dd-MM-yyyy
    
    var info= txtDate.Split('-').Select(Int32.Parse).ToList();
    
     DateTime startDate = new DateTime(info[2], info[1], info[0]);  
                                  //new DateTime (year,Month,day)
    

提交回复
热议问题