C# 中的可排序 (“s”) 格式說明符
可排序標準格式說明符表示自定義日期和時間格式字串。
格式字串由 DateTimeFormatInfo.SortableDateTimePattern 屬性定義。
自定義格式字串。
yyyy'-'MM'-'dd'T'HH':'mm':'ss
示例
using System; class Demo { static void Main() { DateTime date = new DateTime(2018, 9, 5, 2, 12, 40); Console.WriteLine(date.ToString("s")); } }
輸出
2018-09-05T02:12:40
廣告