String.Format,DateTime日期時間格式化集錦

來源:互聯網
上載者:User

標籤:string   for   時間   c   res   5   

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);

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.