Index
Here are some formats to use, for example, in Get-date -format "". These formats are focused on the .NET notation.
Date formats
Day
| d | The day of the month, from 1 to 31. Example: 9 |
| dd | The day of the month, from 01 to 31. Example: 09 |
| ddd | The abbreviated name of the day of the week. Example: Mon |
| dddd | The full name of the day of the week. Example: Monday |
Month
| M | The month, from 1 to 12. Example: 9 |
| MM | The month, from 01 to 12. Example: 09 |
| MMM | The abbreviated name of the month. Example: Sep |
| MMMM | The full name of the month. Example: September |
Year
| y | The year, from 0 to 99. Example: 0900-01-01 -> 0 Example: 2024-01-01 -> 24 |
| yy | The year, from 00 to 99. Example: 0900-01-01 -> 00 Example: 2024-01-01 -> 24 |
| yyy | The year, with a minimum of three digits. Example: 0900-01-01 -> 900 Example: 2024-01-01 -> 2024 |
| yyyy | The year as a four-digit number. Example: 0900-01-01 -> 0900 Example: 2024-01-01 -> 2024 |
| yyyyy | The year as a five-digit number. Example: 0900-01-01 -> 00900 Example: 2024-01-01 -> 02024 |
Time Formats
Hour
| h | The hour, using a 12-hour clock from 1 to 12. Example: 1 |
| hh | The hour, using a 12-hour clock from 01 to 12. Example: 01 |
| H | The hour, using a 24-hour clock from 0 to 23. Example: 13 |
| HH | The hour, using a 24-hour clock from 00 to 23. Example: 13 |
Minute
| m | The minute, from 0 to 59. Example: 4 |
| mm | The minute, from 00 to 59. Example: 04 |
Second
| s | The second, from 0 to 59. Example: 0 |
| ss | The second, from 00 to 59. Example: 00 |
Part of a second
| f | The tenths of a second in a date and time value. Example: 2009-06-15T13:45:30.6175400 -> 6 Example: 2009-06-15T13:45:30.0000500 -> 0 |
| ff | The hundredths of a second in a date and time value. Example: 2009-06-15T13:45:30.6175400 -> 61 Example: 2009-06-15T13:45:30.0000500 -> 00 |
| fff | The milliseconds in a date and time value. Example: 2009-06-15T13:45:30.6175400 -> 617 Example: 2009-06-15T13:45:30.0000500 -> 000 |
| ffff | The ten thousandths of a second in a date and time value. Example: 2009-06-15T13:45:30.6175400 -> 6175 Example: 2009-06-15T13:45:30.0000500 -> 0000 |
AM & PM
| t | The first character of the AM/PM designator. Example: P |
| tt | The AM/PM designator. Example: PM |

Leave a Reply