C#中使用DateTime.ToString()转换输出日期

来源:互联网 发布:朱炫 知乎 编辑:程序博客网 时间:2024/06/17 16:21

发表此帖主要反对博客园的一篇帖子:http://www.cnblogs.com/yjmyzz/archive/2010/10/22/1858333.html

        DateTime dt = DateTime.Now;        Response.Write(dt.ToString("yyyy\\/MM\\/dd HH:mm:ss"));        Response.Write("<br>");        Response.Write(dt.ToString("yyyy/MM/dd HH:mm:ss"));        Response.Write("<br>");        Response.Write(dt.ToString("yyyy-MM-dd HH:mm:ss"));        Response.Write("<br>");        Response.Write(dt.ToString("yyyyMMdd HH:mm:ss"));

输出结果:

2012/09/12 17:21:15
2012/09/12 17:21:15
2012-09-12 17:21:15
20120912 17:21:15


原创粉丝点击