0

I am retrieving date and passing to the function :

Bind(GetDate(Convert.ToString(Session["TransDate"])),
GetDate((Convert.ToDateTime(Session["TransDate"]).AddDays(1)).ToString("MM-dd-yyyy")));

The get date function is described below :

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;
}

it gives me error as :

 "string was not recognized as a valid date time".
4

1 回答 1

0

尝试这个

DateTime.Now.ToString("MM dd yy"");

或者

DateTime dt = DateTime.Now; 
string s = dt.ToString("MM dd yy"");

s= "10 28 13";
于 2013-10-28T06:47:32.130 回答