C#时间设定

using System;
using System.Globalization;

public class MainClass {
   public static void Main(string[] args)  {
       DateTime dt = DateTime.Now;
       String[] format = {
           "d", "D",
           "f", "F",
           "g", "G",
           "m",
           "r",
           "s",
           "t", "T",
           "u", "U",
           "y",
           "dddd, MMMM dd yyyy",
           "ddd, MMM d /"'/"yy",
           "dddd, MMMM dd",
           "M/yy",
           "dd-MM-yy",
       };
       String date;
       for (int i = 0; i < format.Length; i++) {
           //date = dt.ToString(format[i], DateTimeFormatInfo.InvariantInfo);
           date = dt.ToString(format[i]);
           Console.WriteLine(String.Concat(format[i], " :" , date));
       }
 
  /** Output.
    d :2005-6-11
  D :2005年6月11日
    f :2005年6月11日 11:13
  F :2005年6月11日 11:13:14
  g :2005-6-11 11:13
  G :2005-6-11 11:13:14
  m :6月11日
  r :Sat, 11 Jun 2005 11:13:14 GMT
  s :2005-06-11T11:13:14
  t :11:13
  T :11:13:14
  u :2005-06-11 11:13:14Z
  U :2005年6月11日 3:13:14
  y :2005年6月
  dddd, MMMM dd yyyy :星期六, 六月 11 2005
  ddd, MMM d "'"yy :星期六, 六月 11 '05
  dddd, MMMM dd :星期六, 六月 11
  M/yy :6-05
  dd-MM-yy :11-06-05
   */
   }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值