Custom Date & Time Format Strings
- 27 Feb 2020
- 1 Minute to read
- Print
- DarkLight
This documentation version is deprecated, please click here for the latest version.
Custom Date & Time Format Strings
- Updated on 27 Feb 2020
- 1 Minute to read
- Print
- DarkLight
Article summary
Did you find this summary helpful?
Thank you for your feedback
Overview
The following explains how to work with date and time format. A date and time format string provides properties and methods to format dates in different datetime formats.
The following table describes various date time formats and their results. Here we see all the patterns of the DateTime Class.
For more information please visit: https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings
Format | Result |
---|---|
DateTime.Now.ToString("MM/dd/yyyy") | 05/29/2015 |
DateTime.Now.ToString("dddd, dd MMMM yyyy") | Friday, 29 May 2015 |
DateTime.Now.ToString("dddd, dd MMMM yyyy") | Friday, 29 May 2015 05:50 |
DateTime.Now.ToString("dddd, dd MMMM yyyy") | Friday, 29 May 2015 05:50 AM |
DateTime.Now.ToString("dddd, dd MMMM yyyy") | Friday, 29 May 2015 5:50 |
DateTime.Now.ToString("dddd, dd MMMM yyyy") | Friday, 29 May 2015 5:50 AM |
DateTime.Now.ToString("dddd, dd MMMM yyyy HH:mm:ss") | Friday, 29 May 2015 05:50:06 |
DateTime.Now.ToString("MM/dd/yyyy HH:mm") | 05/29/2015 05:50 |
DateTime.Now.ToString("MM/dd/yyyy hh:mm tt") | 05/29/2015 05:50 AM |
DateTime.Now.ToString("MM/dd/yyyy H:mm") | 05/29/2015 5:50 |
DateTime.Now.ToString("MM/dd/yyyy h:mm tt") | 05/29/2015 5:50 AM |
DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss") | 05/29/2015 05:50:06 |
DateTime.Now.ToString("MMMM dd") | May 29 |
DateTime.Now.ToString("yyyy’-‘MM’-‘dd’T’HH’:’mm’:’ss.fffffffK") | 2015-05-16T05:50:06.7199222-04:00 |
DateTime.Now.ToString("ddd, dd MMM yyy HH’:’mm’:’ss ‘GMT’") | Fri, 16 May 2015 05:50:06 GMT |
DateTime.Now.ToString("yyyy’-‘MM’-‘dd’T’HH’:’mm’:’ss") | 2015-05-16T05:50:06 |
DateTime.Now.ToString("HH:mm") | 05:50 |
DateTime.Now.ToString("hh:mm tt") | 05:50 AM |
DateTime.Now.ToString("H:mm") | 5:50 |
DateTime.Now.ToString("h:mm tt") | 5:50 AM |
DateTime.Now.ToString("HH:mm:ss") | 05:50:06 |
DateTime.Now.ToString("yyyy MMMM") | 2015 May |
Was this article helpful?