1. Date formatting method when data control is bound:
Copy codeThe Code is as follows: <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. When using DataBinder. Eval for Data Binding:Copy codeThe Code is as follows: DataBinder. Eval (Container. DataItem, "AddTime", "{0: yyyy-MM-dd }")
3. Use the ToString method to convert the date display format:Copy codeThe Code is as follows: DateTime. Now. ToString ("yyyy-MM-dd HH: mm: ss ")
4. Convert the date display format with the String type:Copy codeThe Code is as follows: String. Format ("{0: yyyy-MM-dd}", DateTime. Now)
5. Convert the date display format using the DateTime. Parse MethodCopy codeThe Code is as follows: DateTime. Parse ("2012-2-22"). ToString ("yyyy-MM-dd ")
6. Convert the date display format using Convert. ToDateTime:Copy codeThe Code is as follows: 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
Description of custom DateTime format
Http://msdn.microsoft.com/zh-cn/library/8kb3ddd4 (v = vs.80). aspx