"d" 형식 지정자는 사용자 지정 날짜 및 시간 형식 문자열을 나타냅니다.
형식 문자열은 문화권의 DateTimeFormatInfo.ShortDatePattern 속성에 의해 정의됩니다.
사용자 지정 형식 문자열은 -
입니다.MM/dd/yyyy
예시
using System;
using System.Globalization;
class Demo {
static void Main() {
DateTime myDate = new DateTime(2018,9, 09);
Console.WriteLine(myDate.ToString("d", DateTimeFormatInfo.InvariantInfo));
Console.WriteLine(myDate.ToString("d", CultureInfo.CreateSpecificCulture("en-US")));
}
} 출력
09/09/2018 9/9/2018