1、新建一个C#窗体应用程序项目,用来做测试用。

3、使用不同的格式转换都可以:// string d1 = "2018-1-1"挢旗扦渌;//需要转换的年月日string d1 = "2018年1月1日";DateTime d2 = DateTime.Parse(d1);//转换后的年月日MessageBox.Show(d2.ToString());效果一样。

时间:2024-10-12 04:08:50
1、新建一个C#窗体应用程序项目,用来做测试用。
3、使用不同的格式转换都可以:// string d1 = "2018-1-1"挢旗扦渌;//需要转换的年月日string d1 = "2018年1月1日";DateTime d2 = DateTime.Parse(d1);//转换后的年月日MessageBox.Show(d2.ToString());效果一样。