How to format the date and time with C# and ASP.NET
DateTime.Now.ToLocalTime()
:6/3/2013 10:35:41 AM
DateTime.Now.ToLongDateString()
: Monday, June 03, 2013
DateTime.Now.ToLongTimeString()
:10:35:41 AM
DateTime.Now.ToShortDateString()
: 6/3/2013
DateTime.Now.ToShortTimeString()
: 10:35 AM
DateTime.Now.ToUniversalTime()
: 6/3/2013 8:35:41 AM
DateTime.Now.ToString()
: 6/3/2013 10:35:41 AM
DateTime.Now.ToString("dd-MM-yyyy")
: 03-06-2013
DateTime.Now.ToString("dd MMM, yyyy")
: 03 Jun, 2013
DateTime.Now.ToString("ddd dd MMM, yyyy")
: Mon 03 Jun, 2013
DateTime.Now.ToString("d")
: 6/3/2013
DateTime.Now.ToString("D")
: Monday, June 03, 2013
DateTime.Now.ToString("f")
: Monday, June 03, 2013 10:35 AM
DateTime.Now.ToString("F")
: Monday, June 03, 2013 10:35:41 AM
DateTime.Now.ToString("g")
: 6/3/2013 10:35 AM
DateTime.Now.ToString("G")
: 6/3/2013 10:35:41 AM
DateTime.Now.ToString("m")
: June 03
DateTime.Now.ToString("M")
: June 03
DateTime.Now.ToString("o")
: 2013-06-03T10:35:41.8516085+02:00
DateTime.Now.ToString("O")
: 2013-06-03T10:35:41.8516085+02:00
DateTime.Now.ToString("s")
: 2013-06-03T10:35:41
DateTime.Now.ToString("t")
: 10:35 AM
DateTime.Now.ToString("T")
: 10:35:41 AM
DateTime.Now.ToString("u")
: 2013-06-03 10:35:41Z
DateTime.Now.ToString("U")
: Monday, June 03, 2013 8:35:41 AM
DateTime.Now.ToString("y")
: June, 2013
DateTime.Now.ToString("Y")
: June, 2013