我有日期时间输入字段,我从中获取日期并将其转换为另一种格式,我的代码
try
{
DateTime dt = dtiFrom.Value.Date;
string format = "DD-MM-YYYY"; // Use this format
MessageBox.Show(dt.ToString(format)); // here its shows result as DD-10-YYYY
DateTime dt1 = Convert.ToDateTime(dt.ToString(format)); // here Error "The string was not recognized as a valid DateTime. There is an unknown word starting at index 0."
}
catch (Exception ee)
{
MessageBox.Show(ee.Message, "Error Message!");
}
我无法根据我的格式转换日期。请任何人帮助我编写代码或建议我一些代码。提前致谢