Format specifier chuẩn Sortable (s) biểu diễn chuỗi định dạng ngày giờ tùy chỉnh.
Chuỗi định dạng được định nghĩa bởi thuộc tính DateTimeFormatInfo.SortableDateTimePattern.
Chuỗi định dạng tùy chỉnh:
yyyy'-'MM'-'dd'T'HH':'mm':'ss
Ví dụ
using System;
class Demo {
static void Main() {
DateTime date = new DateTime(2018, 9, 5, 2, 12, 40);
Console.WriteLine(date.ToString("s"));
}
}
Kết quả
2018-09-05T02:12:40