Tuesday, August 31, 2010

Format System.DateTime in .NET



System.DateTime in ASP.NET


Below are common uses of the DateTime Structure in C#


DateTime.Now; 8/31/2010 12:25:09 PM
DateTime.Now.ToString(); 8/31/2010 12:25:09 PM
DateTime.Now.ToShortTimeString()12:25 PM
DateTime.Now.ToShortDateString()8/31/2010
DateTime.Now.ToLongTimeString()12:25:09 PM
DateTime.Now.ToLongDateString()Tuesday, August 31, 2010





DateTime.Now.ToString("d")8/31/2010
DateTime.Now.ToString("D")Tuesday, August 31, 2010
DateTime.Now.ToString("f")Tuesday, August 31, 2010 12:25 PM
DateTime.Now.ToString("F")Tuesday, August 31, 2010 12:25:09 PM
DateTime.Now.ToString("g")8/31/2010 12:25 PM
DateTime.Now.ToString("G")8/31/2010 12:25:09 PM
DateTime.Now.ToString("m")August 31
DateTime.Now.ToString("r")Tue, 31 Aug 2010 12:25:09 GMT
DateTime.Now.ToString("s")2010-08-31T12:25:09
DateTime.Now.ToString("t")12:25 PM
DateTime.Now.ToString("T")12:25:09 PM
DateTime.Now.ToString("u")2010-08-31 12:25:09Z
DateTime.Now.ToString("U")Tuesday, August 31, 2010 5:25:09 PM
DateTime.Now.ToString("y")August, 2010
DateTime.Now.ToString("dddd, MMMM dd yyyy")Tuesday, August 31 2010
DateTime.Now.ToString("ddd, MMM d "'"yy")Tue, Aug 31 '10
DateTime.Now.ToString("dddd, MMMM dd")Tuesday, August 31
DateTime.Now.ToString("M/yy")8/10
DateTime.Now.ToString("dd-MM-yy")31-08-10


Source: http://www.csharpfriends.com/demos/system.datetime.aspx



No comments:

Post a Comment