DateTime dt = DateTime.Now;
//    Label1.Text = dt.ToString();//2005-11-5 13:21:25
//    Label2.Text = dt.ToFileTime().ToString();//127756416859912816
//    Label3.Text = dt.ToFileTimeUtc().ToString();//127756704859912816
//    Label4.Text = dt.ToLocalTime().ToString();//2005-11-5 21:21:25
//    Label5.Text = dt.ToLongDateString().ToString();//2005年11月5日
//    Label6.Text = dt.ToLongTimeString().ToString();//13:21:25
//    Label7.Text = dt.ToOADate().ToString();//38661.5565508218
//    Label8.Text = dt.ToShortDateString().ToString();//2005-11-5
//    Label9.Text = dt.ToShortTimeString().ToString();//13:21
//    Label10.Text = dt.ToUniversalTime().ToString();//2005-11-5 5:21:25
//     2005-11-5 13:30:28.4412864
//    Label1.Text = dt.Year.ToString();//2005
//    Label2.Text = dt.Date.ToString();//2005-11-5 0:00:00
//    Label3.Text = dt.DayOfWeek.ToString();//Saturday
//    Label4.Text = dt.DayOfYear.ToString();//309
//    Label5.Text = dt.Hour.ToString();//13
//    Label6.Text = dt.Millisecond.ToString();//441
//    Label7.Text = dt.Minute.ToString();//30
//    Label8.Text = dt.Month.ToString();//11
//    Label9.Text = dt.Second.ToString();//28
//    Label10.Text = dt.Ticks.ToString();//632667942284412864
//    Label11.Text = dt.TimeOfDay.ToString();//13:30:28.4412864
//    Label1.Text = dt.ToString();//2005-11-5 13:47:04
//    Label2.Text = dt.AddYears(1).ToString();//2006-11-5 13:47:04
//    Label3.Text = dt.AddDays(1.1).ToString();//2005-11-6 16:11:04
//    Label4.Text = dt.AddHours(1.1).ToString();//2005-11-5 14:53:04
//    Label5.Text = dt.AddMilliseconds(1.1).ToString();//2005-11-5 13:47:04
//    Label6.Text = dt.AddMonths(1).ToString();//2005-12-5 13:47:04
//    Label7.Text = dt.AddSeconds(1.1).ToString();//2005-11-5 13:47:05
//    Label8.Text = dt.AddMinutes(1.1).ToString();//2005-11-5 13:48:10
//    Label9.Text = dt.AddTicks(1000).ToString();//2005-11-5 13:47:04
//    Label10.Text = dt.CompareTo(dt).ToString();//0
////    Label11.Text = dt.Add(?).ToString();//问号为一个时间段
//    Label1.Text = dt.Equals("2005-11-6 16:11:04").ToString();//False
//    Label2.Text = dt.Equals(dt).ToString();//True
//    Label3.Text = dt.GetHashCode().ToString();//1474088234
//    Label4.Text = dt.GetType().ToString();//System.DateTime
//    Label5.Text = dt.GetTypeCode().ToString();//DateTime
   
//    Label1.Text = dt.GetDateTimeFormats('s')[0].ToString();//2005-11-05T14:06:25
//    Label2.Text = dt.GetDateTimeFormats('t')[0].ToString();//14:06
//    Label3.Text = dt.GetDateTimeFormats('y')[0].ToString();//2005年11月
//    Label4.Text = dt.GetDateTimeFormats('D')[0].ToString();//2005年11月5日
//    Label5.Text = dt.GetDateTimeFormats('D')[1].ToString();//2005 11 05
//    Label6.Text = dt.GetDateTimeFormats('D')[2].ToString();//星期六 2005 11 05
//    Label7.Text = dt.GetDateTimeFormats('D')[3].ToString();//星期六 2005年11月5日
//    Label8.Text = dt.GetDateTimeFormats('M')[0].ToString();//11月5日
//    Label9.Text = dt.GetDateTimeFormats('f')[0].ToString();//2005年11月5日 14:06
//    Label10.Text = dt.GetDateTimeFormats('g')[0].ToString();//2005-11-5 14:06
//    Label11.Text = dt.GetDateTimeFormats('r')[0].ToString();//Sat, 05 Nov 2005 14:06:25 GMT

Label1.Text =   string.Format("{0:d}",dt);//2005-11-5
    Label2.Text =   string.Format("{0:D}",dt);//2005年11月5日
    Label3.Text =   string.Format("{0:f}",dt);//2005年11月5日 14:23
    Label4.Text =   string.Format("{0:F}",dt);//2005年11月5日 14:23:23
    Label5.Text =   string.Format("{0:g}",dt);//2005-11-5 14:23
    Label6.Text =   string.Format("{0:G}",dt);//2005-11-5 14:23:23
    Label7.Text =   string.Format("{0:M}",dt);//11月5日
    Label8.Text =   string.Format("{0:R}",dt);//Sat, 05 Nov 2005 14:23:23 GMT
    Label9.Text =   string.Format("{0:s}",dt);//2005-11-05T14:23:23
    Label10.Text = string.Format("{0:t}",dt);//14:23
    Label11.Text = string.Format("{0:T}",dt);//14:23:23
    Label12.Text = string.Format("{0:u}",dt);//2005-11-05 14:23:23Z
    Label13.Text = string.Format("{0:U}",dt);//2005年11月5日 6:23:23
    Label14.Text = string.Format("{0:Y}",dt);//2005年11月
    Label15.Text = string.Format("{0}",dt);//2005-11-5 14:23:23
    Label16.Text = string.Format("{0:yyyyMMddHHmmssffff}",dt);

[Irving]DateTime格式处理大全的更多相关文章

  1. 标准 DateTime 格式字符串

    标准 DateTime 格式字符串 MSDN 标准 DateTime 格式字符串包含一个标准 DateTime 格式说明符字符,该字符表示自定义 DateTime 格式字符串.格式字符串最终定义由格式 ...

  2. 字定义JSON序列化支持datetime格式序列化

    字定义JSON序列化支持datetime格式序列化 由于json.dumps无法处理datetime日期,所以可以通过自定义处理器来做扩展,如: import json from datetime i ...

  3. php 当前时间 当前时间戳和数据库里取出的时间datetime格式进行比较大小

    php 当前时间 当前时间戳和数据库里取出的时间datetime格式进行比较大小 UNIX时间戳转换为日期用函数: date() ,date('Y-m-d H:i:s', 1500219870); 日 ...

  4. 常用SQL时间格式SQLServer中文版的默认的日期字段datetime格式是yyyy-mm-d

    常用SQL时间格式 SQL Server中文版的默认的日期字段datetime格式是yyyy-mm-dd Thh:mm:ss.mmm 例如: select getdate() -- ::08.177 ...

  5. c#数据类型格式转换大全

    来源:网络 1.DateTime   数字型         System.DateTime currentTime=new System.DateTime();    1.1 取当前年月日时分秒   ...

  6. C# 代码往oracle数据库添加datetime格式列

    C# 代码往oracle数据库添加datetime格式列时,不需要在insert语句中为datetime类型使用to_date函数

  7. c# dateTime格式转换为Unix时间戳工具类

    using System; using System.Collections.Generic; using System.Text; namespace TJCFinanceWriteOff.BizL ...

  8. C# sqlite 无法识别的datetime格式 FromOADate

    再读取不可控数据库datetime字段时,遇到了一个奇葩问题——“无法识别的datetime格式” 搞了半天…… 数据库里看:2017-06-06 10:28:30.000 不做处理查询报错:“无法识 ...

  9. C# DATETIME格式转换汇总 根据日期获取星期

    原文:C# DATETIME格式转换汇总 根据日期获取星期 C# DateTime.Now.Year --2019(年) DateTime.Now.Month --9(月) DateTime.Now. ...

随机推荐

  1. Express框架学习总结

    最近学了Express框架,在学习的过程中,参考了一些资料,感觉Express框架比原生Node.js好用多了.下面我将我学习总结的内容如下: Express中文网     http://www.ex ...

  2. 怎样用sourceTree将自己本地的项目上传到github网站上

    前言:GitHub 是基于 Git 的一个代码托管网站.开发者可以将代码在 GitHub 上开源,可以浏览其它项目的代码. 准备工作:1.github网站账号.2.sourceTree软件. 一.在g ...

  3. CODEVS 1069关押罪犯

    题目描述 Description S 城现有两座监狱,一共关押着N 名罪犯,编号分别为1~N.他们之间的关系自然也极 不和谐.很多罪犯之间甚至积怨已久,如果客观条件具备则随时可能爆发冲突.我们用“怨 ...

  4. 洛谷 P1417 烹调方案

    题目背景 由于你的帮助,火星只遭受了最小的损失.但gw懒得重建家园了,就造了一艘飞船飞向遥远的earth星.不过飞船飞到一半,gw发现了一个很严重的问题:肚子饿了~ gw还是会做饭的,于是拿出了储藏的 ...

  5. 在MAC中安装Compass的方法 (转)

    在MAC中通过gem命令安装compass时会出异常,原因是compass版本更新了,一些运行时所用到的依赖软件的版本没能得到更新,故而出现错误.例如,用以下命令安装compass: $ gem in ...

  6. range([start], stop[, step]):产生一个序列,默认从0开始

    range([start], stop[, step]):产生一个序列,默认从0开始 >>> l = range(10) >>> l [0, 1, 2, 3, 4, ...

  7. eclipse 安装git插件

    Eclipse上安装GIT插件EGit及使用 博客分类: GIT   一.Eclipse上安装GIT插件EGit Eclipse的版本eclipse-java-helios-SR2-win32.zip ...

  8. linux如何关闭防火墙

    1) 重启后生效 开启: chkconfig iptables on 关闭: chkconfig iptables off 2) 即时生效,重启后失效 开启: service iptables sta ...

  9. HTTP访问控制(CORS)

    跨站 HTTP 请求(Cross-site HTTP request)是指发起请求的资源所在域不同于该请求所指向资源所在的域的 HTTP请求.比如说,域名A(http://domaina.exampl ...

  10. 虚函数表以及RTTI阅读(阅后焚)

    http://blog.csdn.net/haoel/article/details/1948051/ http://www.cnblogs.com/ustc11wj/archive/2012/08/ ...