.NET 中关于日期时间的格式化处理
2006-02-22 10:30
585 查看
1.绑定时格式化日期方法:
<ASP:BOUNDCOLUMN DATAFIELD= "JoinTime " DATAFORMATSTRING= "{0:yyyy-MM-dd} " >
<ITEMSTYLE WIDTH= "18% " > </ITEMSTYLE >
</ASP:BOUNDCOLUMN >
2.数据控件如DataGrid/DataList等的件格式化日期方法:
e.Item.Cell[0].Text = Convert.ToDateTime(e.Item.Cell[0].Text).ToShortDateString();
3.用String类转换日期显示格式:
String.Format( "yyyy-MM-dd ",yourDateTime);
4.用Convert方法转换日期显示格式:
Convert.ToDateTime("2005-8-23").ToString
("yyMMdd",System.Globalization.DateTimeFormatInfo.InvariantInfo); //支持繁体数据库
5.直接用ToString方法转换日期显示格式:
DateTime.Now.ToString("yyyyMMddhhmmss");
DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss")
6.只显示年月
DataBinder.Eval(Container.DataItem,"starttime","{0:yyyy-M}")
7.显示时间所有部分,包括:年月日时分秒
<asp:BoundColumn DataField="收款时间" HeaderText="收款时间"
DataFormatString="{0:yyyy-MM-dd HH24:mm:ss}">
</asp:BoundColumn>
<ASP:BOUNDCOLUMN DATAFIELD= "JoinTime " DATAFORMATSTRING= "{0:yyyy-MM-dd} " >
<ITEMSTYLE WIDTH= "18% " > </ITEMSTYLE >
</ASP:BOUNDCOLUMN >
2.数据控件如DataGrid/DataList等的件格式化日期方法:
e.Item.Cell[0].Text = Convert.ToDateTime(e.Item.Cell[0].Text).ToShortDateString();
3.用String类转换日期显示格式:
String.Format( "yyyy-MM-dd ",yourDateTime);
4.用Convert方法转换日期显示格式:
Convert.ToDateTime("2005-8-23").ToString
("yyMMdd",System.Globalization.DateTimeFormatInfo.InvariantInfo); //支持繁体数据库
5.直接用ToString方法转换日期显示格式:
DateTime.Now.ToString("yyyyMMddhhmmss");
DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss")
6.只显示年月
DataBinder.Eval(Container.DataItem,"starttime","{0:yyyy-M}")
7.显示时间所有部分,包括:年月日时分秒
<asp:BoundColumn DataField="收款时间" HeaderText="收款时间"
DataFormatString="{0:yyyy-MM-dd HH24:mm:ss}">
</asp:BoundColumn>
相关文章推荐
- .NET 中关于日期时间的格式化处理
- .NET 中关于日期时间的格式化处理
- [转].NET 中日期和时间的格式化处理
- c#.NET 中关于日期时间的格式化处理
- c#.NET 中关于日期时间的格式化处理
- C#.NET 中关于日期时间的格式化处理 (转)
- .NET 中日期和时间的格式化处理
- .net日期时间格式化处理
- c#.NET 中关于日期时间的格式化处理 (转)
- 关于c#对日期时间字符串的格式化操作
- .net 日期时间格式化
- python中关于日期时间处理的问答集锦
- 开发中关于日期的处理:NSDate中取出日期、取出时间等
- 关于日期时间的处理
- jsp 中关于日期时间处理的几个问题
- 转自博客园的一篇关于日期格式的文字《.NET中DateTime时间格式转换(附用户定义格式)》
- python中关于日期时间处理的问答集锦
- .Net日期时间格式化输出大全 DateTime.ToString(?)
- 关于json时间字符串格式化处理
- php处理excel时间数据--——使用PHPExcel判别和格式化Excel中的日期格式