1. Data Control Binding Format Date method:
<asp:boundcolumn datafield= "Addtime" headertext= "Add Time" dataformatstring= "{0:yyyy-mm-dd HH:mm}></asp: Boundcolumn>
<asp:boundfield datafield= "Addtime" headertext= "Add Time" dataformatstring= "{0:yyyy-mm-dd}"/>
2. Use DataBinder.Eval for data binding:
DataBinder.Eval (Container.DataItem, "Addtime", "{0:YYYY-MM-DD}")
3. Convert the date display format directly with the ToString method:
DateTime.Now.ToString ("Yyyy-mm-dd HH:mm:ss")
4. Use the string class to convert the date display format:
String.Format ("{0:yyyy-mm-dd}", DateTime.Now)
5. Convert the date display format using the DateTime.Parse method
DateTime.Parse ("2012-2-22"). ToString ("Yyyy-mm-dd")
6. Convert the date display format using the Convert.todatetime method:
Convert.todatetime ("2012-12-21"). ToString ("Yyyy-mm-dd")
Standard DateTime format specifier
HTTP://MSDN.MICROSOFT.COM/ZH-CN/LIBRARY/AZ4SE3K1 (v=vs.80). aspx
Custom DateTime format specifier
HTTP://MSDN.MICROSOFT.COM/ZH-CN/LIBRARY/8KB3DDD4 (v=vs.80). aspx