I am totally new at Powershell and I need to get just hour and minutes in a script.
I currently have this:
Join Stack Overflow to learn, share knowledge, and build your career.
I am totally new at Powershell and I need to get just hour and minutes in a script.
I currently have this:
You almost have it; instead of g
, use:
hh
for the hour in 12-hour formatHH
for the hour in 24-hour formatmm
for the minutesFor instance Get-Date -Format hh:mm
will return the 12-hour time as "04:55", while Get-Date -Format HH
will just return the hours in 24-hour time.
The full list of possible formats are at documented by Microsoft: Custom Date and Time Format Strings