March 11th, 2013

PowerTip: Display the Date in Month, Day, Year Format

Doctor Scripto
Scripter

Summary: Learn how to use Windows PowerShell to display the date in a month, day, and two-digit year format.

Hey, Scripting Guy! Question How can I use Windows PowerShell to display the date in a month, day, and two-digit number format with a hyphen between each of the elements?

Hey, Scripting Guy! Answer Use the ToString method from the Get-Date cmdlet and specify a pattern to achieve your desired results:

PS C:\> (get-date).ToString(“MM-dd-yy”)

03-11-13

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.