Search content within the blog

Monday, December 22, 2008

DateTime Structure in C#

Below are common uses of the DateTime Structure in C#

DateTime.Now; 12/22/2008 5:29:25 AM
DateTime.Now.ToString(); 12/22/2008 5:29:25 AM
DateTime.Now.ToShortTimeString() 5:29 AM
DateTime.Now.ToShortDateString() 12/22/2008
DateTime.Now.ToLongTimeString() 5:29:25 AM
DateTime.Now.ToLongDateString() Monday, December 22, 2008




DateTime.Now.ToString("d") 12/22/2008
DateTime.Now.ToString("D") Monday, December 22, 2008
DateTime.Now.ToString("f") Monday, December 22, 2008 5:29 AM
DateTime.Now.ToString("F") Monday, December 22, 2008 5:29:25 AM
DateTime.Now.ToString("g") 12/22/2008 5:29 AM
DateTime.Now.ToString("G") 12/22/2008 5:29:25 AM
DateTime.Now.ToString("m") December 22
DateTime.Now.ToString("r") Mon, 22 Dec 2008 05:29:25 GMT
DateTime.Now.ToString("s") 2008-12-22T05:29:25
DateTime.Now.ToString("t") 5:29 AM
DateTime.Now.ToString("T") 5:29:25 AM
DateTime.Now.ToString("u") 2008-12-22 05:29:25Z
DateTime.Now.ToString("U") Monday, December 22, 2008 10:29:25 AM
DateTime.Now.ToString("y") December, 2008
DateTime.Now.ToString("dddd, MMMM dd yyyy") Monday, December 22 2008
DateTime.Now.ToString("ddd, MMM d "'"yy") Mon, Dec 22 '08
DateTime.Now.ToString("dddd, MMMM dd") Monday, December 22
DateTime.Now.ToString("M/yy") 12/08
DateTime.Now.ToString("dd-MM-yy") 22-12-08

No comments:

Post a Comment