Categories

Tools

bitdefender

1&1 Web Hosting

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

Posted in ASP.NET by MdmSoft

If our work has been of help, you can help us with a small donation...
Our programmers will thank you!



All information contained in this web site are the property of MdmSoft. The information is provided "as is", MdmSoft will not be liable for any misuse of the code contained in these pages, nor can it be for inaccuracies, grammatical errors or other factors that may have caused damage or lost earnings. MdmSoft is not responsible for the content of comments posted by users.
The examples in this area have the educational and demonstration purposes only, and may be copied only for your reference, but cannot be used for commercial purposes, or for any other purpose, without the express written consent of MdmSoft.
MdmSoft also reserves the right to change, without notice, to your liking this web site, the pages and its sections, and may suspend temporarily or definitely the various services included on this site.
While using this site, you agree to have read and accepted our Terms of Service and Privacy Policy.