C #DatetimeDate Format display
Reprinted from: http://blog.csdn.net/angleoldhen/archive/2006/10/16/1336940.aspx
1. Date Format Method for binding:
<Asp: boundcolumn datafield = "jointime" dataformatstring = "{0: yyyy-mm-dd}">
<Itemstyle width = "18%" type = "option" text = "option"> </itemstyle>
</ASP: boundcolumn>
2. How to format data items such as DataGrid and datalist:
E. Item. Cell [0]. Text = convert. todatetime (E. Item. Cell [0]. Text). to1_datestring ();
3. Convert the date display format with the string type:
String. Format ("yyyy-mm-dd", yourdatetime );
4. Convert the date display format using the convert method:
Convert. todatetime ("2005-8-23"). tostring
("Yymmdd", system. Globalization. datetimeformatinfo. invariantinfo); // supports traditional Chinese databases.
5. Convert the date display format directly using the tostring method:
Datetime. Now. tostring ("yyyymmddhhmmss ");
Datetime. Now. tostring ("yyyy/mm/dd hh: mm: SS ")
6. show only the year and month
Databinder. eval (container. dataitem, "starttime", "{0: yyyy-m }")
7. display all time parts, including: year, month, day, hour, minute, and second
<Asp: boundcolumn datafield = "receipt time" headertext = "receipt time"
Dataformatstring = "{0: yyyy-mm-dd hh24: mm: SS}">
</ASP: boundcolumn>