C# 中的完全日期短時間 (“f”) 格式說明符
完全日期短時間標準格式說明符表示長時間日期(“D”)和短時間(“t”)模式的組合。
使用DateTime來設定日期。
DateTime myDate = new DateTime(2018, 8, 29, 1, 10, 0);
現在,使用以下格式說明符(“f”)-
myDate.ToString("f", CultureInfo.CreateSpecificCulture("en-US"))
以下是示例 -
示例
using System; using System.Globalization; class Demo { static void Main() { DateTime myDate = new DateTime(2018, 8, 29, 1, 10, 0); Console.WriteLine(myDate.ToString("f",CultureInfo.CreateSpecificCulture("en-US"))); } }
輸出
Wednesday, August 29, 2018 1:10 AM
廣告