C# 中的月份 (“M”、“m”) 格式說明符


月份標準格式說明符表示一個自定義日期和時間格式字串。

格式字串由當前的 DateTimeFormatInfo.MonthDayPattern 屬性定義。

自定義格式字串 -

MMMM dd

示例

 即時演示

using System;
using System.Globalization;
class Demo {
   static void Main() {
      DateTime date = new DateTime(2018, 6, 11, 9, 15, 0);
      Console.WriteLine(date.ToString("m", CultureInfo.CreateSpecificCulture("en-us")));
   }
}

輸出

June 11

更新時間: 2020 年 6 月 23 日

287 次瀏覽

開啟你的 職業生涯

完成課程獲得認證

開始學習
廣告