惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

H
Help Net Security
博客园 - Franky
GbyAI
GbyAI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
爱范儿
爱范儿
IT之家
IT之家
酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
博客园_首页
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Announcements
Recent Announcements
Scott Helme
Scott Helme
有赞技术团队
有赞技术团队
M
MIT News - Artificial intelligence
C
CERT Recently Published Vulnerability Notes
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Jina AI
Jina AI
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
L
LangChain Blog
L
LINUX DO - 最新话题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Hacker News: Front Page
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
AI
AI
T
Troy Hunt's Blog
Microsoft Azure Blog
Microsoft Azure Blog
阮一峰的网络日志
阮一峰的网络日志
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
罗磊的独立博客
S
Secure Thoughts
大猫的无限游戏
大猫的无限游戏
博客园 - 叶小钗
人人都是产品经理
人人都是产品经理
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 三生石上(FineUI控件)
S
Security @ Cisco Blogs
Cloudbric
Cloudbric
E
Exploit-DB.com RSS Feed
Attack and Defense Labs
Attack and Defense Labs

博客园 - 老姜

SQL Server 2008 收缩日志 【原创】自定义Membership,KSPMembership发布,支持多数据库(mysql/oracle/sqlserver) 日志与工厂模式(二) 日志与工厂模式(一) The timeout period elapsed prior to obtaining a connection from the pool.数据库连接池满的原因 Asp.net mvc 入门介绍(公司内部讲座学习资料) 反射复习(Reflection) SERV-U 防火墙设置 检索 COM 类工厂中 CLSID 为 {000209FF-0000-0000-C000-000000000046} 的组件时失败 的解决方法 ASP.NET MVC 多语言解决方案 DLinq 仅支持SQL SERVER ,不支持Mysql/Oracle 从SQL SERVER 2000到SQL SERVER 2005 视图中存在 ORDER BY 语句的完全解决方案 一个中型OA系统的架构过程(二) Enterprise Library for .NET Framework 2.0 掌握 ASP.NET 之路:自定义实体类简介(转载-ORM、泛型等) 转载:一个中型OA系统的架构过程(一) WebServices层次划分 SQL SERVER 2000 存储过程不支持数组的解决方法! 通过日志来恢复到你要的时点
C#(ASP.NET)DateTime日期类型格式化显示 (转载)
老姜 · 2008-01-07 · via 博客园 - 老姜

转载:http://blog.csdn.net/codetian/archive/2007/07/26/1710157.aspx
方便自己查找所以记录下来。

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> 

8.格式化从数据库中读取的时间

 Convert.ToDateTime(dr["MT_ENDate"]).ToShortDateString();

Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1710157