Partager via


PowerTip: Customize How PowerShell Displays a Date

Summary: Easily customize the way Windows PowerShell displays a date.

Hey, Scripting Guy! Question How can I use Windows PowerShell to easily display the date as day-dash-month-dash-four-digit year?

Hey, Scripting Guy! Answer Use the Get-Date cmdlet,specify a custom format by using the Formatparameter, and use dd for the date, M for the month and yyyy for a four-digit year (this is case sensitive):

Get-Date -Format "dd-M-yyyy"