zoukankan      html  css  js  c++  java
  • DateTime.Now.ToString 中的参数问题

    DateTime.Now.ToString根据参数不同输出不同内容,功能很强的,总结一下。

    [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);
               Console.WriteLine(String.Concat(format[i], " :" , date));
           }
      /** Output.
       *
       * d :08/17/2000
       * D :Thursday, August 17, 2000
       * f :Thursday, August 17, 2000 16:32
       * F :Thursday, August 17, 2000 16:32:32
       * g :08/17/2000 16:32
       * G :08/17/2000 16:32:32
       * m :August 17
       * r :Thu, 17 Aug 2000 23:32:32 GMT
       * s :2000-08-17T16:32:32
       * t :16:32
       * T :16:32:32
       * u :2000-08-17 23:32:32Z
       * U :Thursday, August 17, 2000 23:32:32
       * y :August, 2000
       * dddd, MMMM dd yyyy :Thursday, August 17 2000
       * ddd, MMM d "'"yy :Thu, Aug 17 '00
       * dddd, MMMM dd :Thursday, August 17
       * M/yy :8/00
       * dd-MM-yy :17-08-00
       */
       }
    }

  • 相关阅读:
    发送trim值
    关一些时钟
    不同频率下的pwm配置
    c#鼠标在控件上面,然后显示文字
    C#通过文件路径截取对应的文件夹路径
    C#随机生成连续多少个十六进制数字
    C#检测串口被拔掉等一些触发事件合集
    c#按键Up和Down对Textbox的内容加1减1
    软件架构师工作历程
    软件架构阅读6
  • 原文地址:https://www.cnblogs.com/skywind/p/984897.html
Copyright © 2011-2022 走看看