String.Format,DateTime日期时间格式化集锦,备忘录

//String.Format,DateTime日期时间格式化集锦,备忘录
DateTime dt = DateTime.Now;//2010年10月4日 17点05分
string str = "";
//str = string.Format("{0:y yy yyy yyyy}", dt); //10 10 2010 2010
//str = String.Format("{0:M MM MMM MMMM}", dt); //10 10 十月 十月
//str = String.Format("{0:d dd ddd dddd}", dt); //4 04 周一 星期一
//str = String.Format("{0:h hh H HH}", dt);   // 5 05 17 17
//str = String.Format("{0:m mm}", dt);  //8 08
//str = String.Format("{0:s ss}", dt);  //3 03
//str = String.Format("{0:f ff fff ffff}", dt);  //9 95 953 9530
//str = String.Format("{0:F FF FFF FFFF}", dt);  //9 95 953 953
//str = String.Format("{0:t tt}", dt);  //下 下午
//str = String.Format("{0:z zz zzz}", dt);  //+8 +08 +08:00

//str = String.Format("{0:d/M/yyyy HH:mm:ss}", dt); //4-10-2010 17:16:50
//str = String.Format("{0:M/d/yyyy}", dt);    //10-4-2010
//str = String.Format("{0:MM/dd/yyyy}", dt);          //10-04-2010
//str = String.Format("{0:ddd, MMM d, yyyy}", dt);    //周一, 十月 4, 2010
//str = String.Format("{0:dddd, MMMM d, yyyy}", dt);  //星期一, 十月 4, 2010
//str = String.Format("{0:MM/dd/yy}", dt);            //10-04-10
//str = String.Format("{0:MM/dd/yyyy}", dt);          //10-04-2010

//str = String.Format("{0:t}", dt);  //17:29
//str = String.Format("{0:d}", dt);  //2010-10-4
//str = String.Format("{0:T}", dt);  //17:29:59
//str = String.Format("{0:D}", dt);  //2010年10月4日
//str = String.Format("{0:f}", dt);  //2010年10月4日 17:30
//str = String.Format("{0:F}", dt);  //2010年10月4日 17:31:11
//str = String.Format("{0:g}", dt);  //2010-10-4 17:35
//str = String.Format("{0:G}", dt);  //2010-10-4 17:36:18
//str = String.Format("{0:m}", dt);  //10月4日
//str = String.Format("{0:y}", dt);  //2010年10月
//str = String.Format("{0:r}", dt);  //Mon, 04 Oct 2010 17:37:25 GMT
//str = String.Format("{0:s}", dt);  //2010-10-04T17:37:43
str = String.Format("{0:u}", dt);  //2010-10-04 17:38:01Z

Response.Write(str);
Response.End();




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值