[C#] DateTime.ToString

자주쓰는 문법인데도 매번 까먹는거같다.

DateTime.ToString([형식]);

String[] formats = { "G", "MM/yyyy", @"MM\/dd\/yyyy HH:mm",
                           "yyyyMMdd" };

G : 8/18/2015 1:31:17 PM

MM/yyyy : 08/2015

MM\/dd\/yyyy HH:mm : 08/18/2015 13:31

yyyyMMdd : 20150818

string[] standardFmts = {"d", "D", "f", "F", "g", "G", "m", "o", 
                               "R", "s", "t", "T", "u", "U", "y"};

d : 6/15/2008

D : Sunday, June 15, 2008

f : Sunday, June 15, 2008 9:15 PM

F : Sunday, June 15, 2008 9:15:07 PM

g : 6/15/2008 9:15 PM

G : 6/15/2008 9:15:07 PM

m : June 15

o : 2008-06-15T21:15:07.0000000

R : Sun, 15 Jun 2008 21:15:07 GMT

s : 2008-06-15T21:15:07

t : 9:15 PM

T : 9:15:07 PM

u : 2008-06-15 21:15:07Z

U : Monday, June 16, 2008 4:15:07 AM

y : June, 2008

string[] customFmts = {"h:mm:ss.ff t", "d MMM yyyy", "HH:mm:ss.f", 
                             "dd MMM HH:mm:ss", @"\Mon\t\h\: M", "HH:mm:ss.ffffzzz" };

h:mm:ss.ff t: 9:15:07.00 P

d MMM yyyy : 15 Jun 2008

HH:mm:ss.f : 21:15:07.0

dd MMM HH:mm:ss : 15 Jun 21:15:07

\Mon\t\h\: M : Month: 6

HH:mm:ss.ffffzzz : 21:15:07.0000-07:00

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


							

Post Author: 김 키티

댓글 남기기

이메일은 공개되지 않습니다. 필수 입력창은 * 로 표시되어 있습니다