我正在检索日期并传递给函数:
Bind(GetDate(Convert.ToString(Session["TransDate"])),
GetDate((Convert.ToDateTime(Session["TransDate"]).AddDays(1)).ToString("MM-dd-yyyy")));
获取日期功能如下所述:
private String GetDate(String strDate)
{
String strDate1 = String.Empty;
if (strDate != "")
{
String[] arrDate = strDate.Split('/');
if (arrDate.Length == 1)
{
arrDate = strDate.Split('-');
}
strDate1 = arrDate[1] + "/" + arrDate[0] + "/" + arrDate[2];
}
return strDate1;
}
它给了我错误:
"string was not recognized as a valid date time".
答案 0 :(得分:0)
试试这个
DateTime.Now.ToString("MM dd yy"");
或
DateTime dt = DateTime.Now;
string s = dt.ToString("MM dd yy"");
s= "10 28 13";