본문 바로가기
프로그래밍/C Sharp

표준 날짜의 문자열 표현 형식

by 이데렐라 2015. 7. 9.
반응형

날짜간 계산이 필요한데 날짜 데이터가 아닌 문자열 장난을 쳐놨기 때문에

해당 문자열 형식을 참고로 날짜 형변환으로 처리할 수 밖에 없었다. 귀.찮.게.

 

DateTime.GetDateTimeFormats

 

이 인스턴스의 값을 표준 날짜 및 시간 서식 지정자에서 지원하는 모든 문자열 표현으로 변환합니다.

DateTime.GetDateTimeFormats(Char) 메서드에서 "d", "D", "f", "F", "g", "G", "m", "o", "r", "s", "t", "T", "u", "U", 및 "y" 표준 형식 문자열로 인해 독립된 호출에 의해 반환된 문자열 배열을 결합하기 위함입니다.

 

네임스페이스:  System
어셈블리:  mscorlib(mscorlib.dll)

 

DateTime july28 = new DateTime(2009, 7, 28, 5, 23, 15, 16);

string[] july28Formats = july28.GetDateTimeFormats();

// Print out july28 in all DateTime formats using the default culture.
foreach (string format in july28Formats) {
Console.WriteLine(format);
}

7/28/2009
7/28/09
07/28/09
07/28/2009
09/07/28
2009-07-28
28-Jul-09
Tuesday, July 28, 2009
July 28, 2009
Tuesday, 28 July, 2009
28 July, 2009
Tuesday, July 28, 2009 5:23 AM
Tuesday, July 28, 2009 05:23 AM
Tuesday, July 28, 2009 5:23
Tuesday, July 28, 2009 05:23
July 28, 2009 5:23 AM
July 28, 2009 05:23 AM
July 28, 2009 5:23
July 28, 2009 05:23
Tuesday, 28 July, 2009 5:23 AM
Tuesday, 28 July, 2009 05:23 AM
Tuesday, 28 July, 2009 5:23
Tuesday, 28 July, 2009 05:23
28 July, 2009 5:23 AM
28 July, 2009 05:23 AM
28 July, 2009 5:23
28 July, 2009 05:23
Tuesday, July 28, 2009 5:23:15 AM
Tuesday, July 28, 2009 05:23:15 AM
Tuesday, July 28, 2009 5:23:15
Tuesday, July 28, 2009 05:23:15
July 28, 2009 5:23:15 AM
July 28, 2009 05:23:15 AM
July 28, 2009 5:23:15
July 28, 2009 05:23:15
Tuesday, 28 July, 2009 5:23:15 AM
Tuesday, 28 July, 2009 05:23:15 AM
Tuesday, 28 July, 2009 5:23:15
Tuesday, 28 July, 2009 05:23:15
28 July, 2009 5:23:15 AM
28 July, 2009 05:23:15 AM
28 July, 2009 5:23:15
28 July, 2009 05:23:15
7/28/2009 5:23 AM
7/28/2009 05:23 AM
7/28/2009 5:23
7/28/2009 05:23
7/28/09 5:23 AM
7/28/09 05:23 AM
7/28/09 5:23
7/28/09 05:23
07/28/09 5:23 AM
07/28/09 05:23 AM
07/28/09 5:23
07/28/09 05:23
07/28/2009 5:23 AM
07/28/2009 05:23 AM
07/28/2009 5:23
07/28/2009 05:23
09/07/28 5:23 AM
09/07/28 05:23 AM
09/07/28 5:23
09/07/28 05:23
2009-07-28 5:23 AM
2009-07-28 05:23 AM
2009-07-28 5:23
2009-07-28 05:23
28-Jul-09 5:23 AM
28-Jul-09 05:23 AM
28-Jul-09 5:23
28-Jul-09 05:23
7/28/2009 5:23:15 AM
7/28/2009 05:23:15 AM
7/28/2009 5:23:15
7/28/2009 05:23:15
7/28/09 5:23:15 AM
7/28/09 05:23:15 AM
7/28/09 5:23:15
7/28/09 05:23:15
07/28/09 5:23:15 AM
07/28/09 05:23:15 AM
07/28/09 5:23:15
07/28/09 05:23:15
07/28/2009 5:23:15 AM
07/28/2009 05:23:15 AM
07/28/2009 5:23:15
07/28/2009 05:23:15
09/07/28 5:23:15 AM
09/07/28 05:23:15 AM
09/07/28 5:23:15
09/07/28 05:23:15
2009-07-28 5:23:15 AM
2009-07-28 05:23:15 AM
2009-07-28 5:23:15
2009-07-28 05:23:15
28-Jul-09 5:23:15 AM
28-Jul-09 05:23:15 AM
28-Jul-09 5:23:15
28-Jul-09 05:23:15
July 28
July 28
2009-07-28T05:23:15.0160000
2009-07-28T05:23:15.0160000
Tue, 28 Jul 2009 05:23:15 GMT
Tue, 28 Jul 2009 05:23:15 GMT
2009-07-28T05:23:15
5:23 AM
05:23 AM
5:23
05:23
5:23:15 AM
05:23:15 AM
5:23:15
05:23:15
2009-07-28 05:23:15Z
Tuesday, July 28, 2009 12:23:15 PM
Tuesday, July 28, 2009 12:23:15 PM
Tuesday, July 28, 2009 12:23:15
Tuesday, July 28, 2009 12:23:15
July 28, 2009 12:23:15 PM
July 28, 2009 12:23:15 PM
July 28, 2009 12:23:15
July 28, 2009 12:23:15
Tuesday, 28 July, 2009 12:23:15 PM
Tuesday, 28 July, 2009 12:23:15 PM
Tuesday, 28 July, 2009 12:23:15
Tuesday, 28 July, 2009 12:23:15
28 July, 2009 12:23:15 PM
28 July, 2009 12:23:15 PM
28 July, 2009 12:23:15
28 July, 2009 12:23:15
July, 2009
July, 2009

 

출처: MSDN

https://msdn.microsoft.com/ko-kr/library/fyk2998w(v=vs.110).aspx

반응형

댓글