Appendix I. .NET DateTime Formatting
DateTime format strings convert a DateTime
object to one of several standard formats, as listed in Table I-1.
Format specifier | Name | Description | Example |
| Short date | The culture’s short date format. |
PS >"{0:d}" -f [DateTime] "01/23/4567" 1/23/4567
|
| Long date | The culture’s long date format. |
PS >"{0:D}" -f [DateTime] "01/23/4567" Friday, January 23, 4567
|
| Full date/short time | Combines the long date and short time format patterns. |
PS >"{0:f}" -f [DateTime] "01/23/4567" Friday, January 23, 4567 12:00 AM
|
| Full date/long time | Combines the long date and long time format patterns. |
PS >"{0:F}" -f [DateTime] "01/23/4567" Friday, January 23, 4567 12:00:00 AM
|
| General date/ short time | Combines the short date and short time format patterns. |
PS >"{0:g}" -f [DateTime] "01/23/4567" 1/23/4567 12:00 AM
|
| General date/long time | Combines the short date and long time format patterns. |
PS >"{0:G}" -f [DateTime] "01/23/4567" 1/23/4567 12:00:00 AM
|
| Month day | The culture’s |
PS >"{0:M}" -f [DateTime] "01/23/4567" January 23
|
| Round-trip date/time | The date formatted with a pattern that guarantees the string (when parsed) will result in the original DateTime again. |
PS >"{0:o}" -f [DateTime] "01/23/4567" 4567-01-23T00:00:00.0000000
|
| RFC1123 | The standard RFC1123 format pattern. |
PS >"{0:R}" -f [DateTime] "01/23/4567" Fri, 23 Jan 4567 00:00:00 GMT
|
| Sortable | Sortable format pattern. Conforms to ISO 8601, and provides ... |
Get Windows PowerShell Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.