The following is the original post http://www.cnblogs.com/richinger/articles/113085.html
In programming, you often need to convert the date variable into a string.
Convert to strings of different formats
Below are some common conversions and conversion results:
Private void form1_load (Object sender, system. eventargs E)
{
// Textbox1.text = datetime. Now. tostring ("DD/MM/YYYY ");
// Textbox1.text = datetime. Now. dayofyear. tostring ();
Textbox1.text = datetime. Now. tostring ("D ");
Textbox2.text = datetime. Now. tostring ("D ");
Textbox3.text = datetime. Now. tostring ("G ");
Textbox6.text = datetime. Now. tostring ("G ");
Textbox5.text = datetime. Now. tostring ("T ");
Textbox4.text = datetime. Now. tostring ("T ");
Textbox12.text = datetime. Now. tostring ("F ");
Textbox11.text = datetime. Now. tostring ("F ");
Textbox10.text = datetime. Now. tostring ("M ");
Textbox9.text = datetime. Now. tostring ("R ");
Textbox8.text = datetime. Now. tostring ("S ");
Textbox7.text = datetime. Now. tostring ("U ");
Textbox13.text = datetime. Now. tostring ("Y ");
Textbox14.text = datetime. Now. tostring ("Y ");
}
The following is the result of another method conversion:
private void form2_load (Object sender, system. eventargs e)
{< br>
textbox1.text = datetime. now. tostring ("m/D/YYYY");
textbox2.text = datetime. now. tostring ("mm/DD/YY");
textbox3.text = datetime. now. tostring ("D-Mmmm-yy");
textbox6.text = datetime. now. tostring ("ddmmyyyy");
textbox5.text = datetime. now. tostring ("DD, mm, yyyy, YYYY");
textbox4.text = datetime. now. tostring ("mm DD, YYYY");
Textbox12.text = datetime. Now. tostring ("YYYY ");
Textbox11.text = datetime. Now. tostring ("mm Month ");
Textbox10.text = datetime. Now. tostring ("DD ");
Textbox9.text = datetime. Now. tostring ("HH: mm: SS ");
Textbox8.text = datetime. Now. tostring ("m/D/yyyy h: mm ");
Textbox7.text = datetime. Now. tostring ("H: mm: SS ");
}