C#.NET 中关于日期时间的格式化处理 (转)
来源:互联网 发布:linux read write 编辑:程序博客网 时间:2024/05/16 06:34
1.绑定时格式化日期方法: 2.数据控件如DataGrid/DataList等的件格式化日期方法: e.Item.Cell[0].Text = Convert.ToDateTime(e.Item.Cell[0].Text).ToShortDateString(); 3.用String类转换日期显示格式: String.Format("yyyy-MM-dd",yourDateTime); String.Format("yyyy'/'MM'/'dd",yourDateTime); String.Format("yyyy/'//'MM/'//'",yourDateTime); 4.用Convert方法转换日期显示格式: Convert.ToDateTime("2005-8-23").ToString ("yyMMdd",System.Globalization.DateTimeFormatInfo.InvariantInfo); //支持繁体数据库 Convert.ToDateTime("dd/MM/yyyy").ToString ("yyMMdd",System.Globalization.DateTimeFormatInfo.InvariantInfo); 5.直接用ToString方法转换日期显示格式: DateTime.Now.ToString("yyyyMMddhhmmss"); DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") 6.只显示年月 DataBinder.eval_r(Container.DataItem,"starttime","{0:yyyy-M}") 7.显示时间所有部分,包括:年月日时分秒 8、隐藏代码: protected string CutTime (object time) { System.DateTime currentTime = new System.DateTime(); return Convert.ToDateTime(time).ToString("yy-MM-dd",System.Globalization.DateTimeFormatInfo.InvariantInfo); } 下面是html代码:
- c#.NET 中关于日期时间的格式化处理 (转)
- C#.NET 中关于日期时间的格式化处理 (转)
- c#.NET 中关于日期时间的格式化处理
- .NET 中关于日期时间的格式化处理
- .NET 中关于日期时间的格式化处理
- .net日期时间格式化处理
- .net日期时间格式化(转)
- VB.net中时间和日期的格式化
- .net日期时间格式化
- .net 日期时间格式化
- ASP.Net中对时间的格式化处理
- Linux C 获取格式化的日期时间
- Linux C 获取格式化的日期时间
- 关于日期时间的处理
- VB.NET中,时间日期数据类型的处理与常见问题
- C#日期时间格式化处理
- jsp 中关于日期时间处理的几个问题
- 在mysql数据库中关于日期时间字段的处理
- inner join的意义
- 抓紧时间学习oracle
- 在IIS5.1下布署asp.net mvc2
- 两岸正架设另一座新桥——文化桥
- 一对一延迟加载问题探讨
- C#.NET 中关于日期时间的格式化处理 (转)
- css下拉菜单制作原理
- 一场关于YUI3/jQuery的精彩辩论
- 保障Web安全的一些最佳实践
- 囤积的各种资料~
- 内存碎片之如何产生
- WinCE OAL架构分析
- JSP在线统计
- Google和百度、雅虎的站内搜索代码