Convert a string to a datetime

后端 未结 5 903
鱼传尺愫
鱼传尺愫 2020-11-27 18:50

I am developing asp.net site using vb framework 3.5.

Im having difficulties converting string data into Date I tried using

5条回答
  •  心在旅途
    2020-11-27 19:45

    Nobody mentioned this, but in some cases the other method fails to recognize the datetime...

    You can try this instead, which will convert the specified string representation of a date and time to an equivalent date and time value

    string iDate = "05/05/2005";
    DateTime oDate = Convert.ToDateTime(iDate);
    MessageBox.Show(oDate.Day + " " + oDate.Month + "  " + oDate.Year );
    

提交回复
热议问题