In a previous tip we published the list of placeholders to define datetime patterns. You can use the very same placeholders to define your own datetime output formats, too. Check out these examples:
PS> Get-Date -format 'd MMM yyyy'
30 Mar 2012 PS> Get-Date -format 'yyyyMMddHHmmss' 20120330140030
Here's again the list of placeholders you can use to format your output:
d | Day of month 1-31 |
dd | Day of month 01-31 |
ddd | Day of month as abbreviated weekday name |
dddd | Weekday name |
h | Hour from 1-12 |
H | Hour from 1-24 |
hh | Hour from 01-12 |
HH | Hour from 01-24 |
m | Minute from 0-59 |
mm | Minute from 00-59 |
M | Month from 1-12 |
MM | Month from 01-12 |
MMM | Abbreviated Month Name |
MMMM | Month name |
s | Seconds from 1-60 |
ss | Seconds from 01-60 |
t | A or P (for AM or PM) |
tt | AM or PM |
yy | Year as 2-digit |
yyyy | Year as 4-digit |
z | Timezone as one digit |
zz | Timezone as 2-digit |
zzz | Timezone |