String转换DateTime格式

DateTime   dt;  
     
  DateTimeFormatInfo   dtFormat   =   new   System.Globalization.DateTimeFormatInfo();  
  dtFormat.ShortDatePattern="yy-MM-dd"   ;  
  dt=Convert.ToDateTime("04-05-06",dtFormat);  
  Response.Write(dt.ToString("yyyy-MM-dd"));  
   
  dtFormat.ShortDatePattern="MM-dd-yy"   ;  
  dt=Convert.ToDateTime("04-05-06",dtFormat);  
  Response.Write(dt.ToString("yyyy-MM-dd"));  
   
  dtFormat.ShortDatePattern="dd-MM-yy"   ;  
  dt=Convert.ToDateTime("04-05-06",dtFormat);  
  Response.Write(dt.ToString("yyyy-MM-dd"));
原文地址:https://www.cnblogs.com/mxh691/p/1281031.html