How to do Get-Date to show me this format 2018-01-10 and that does not show the time?
I was currently using Get-Format s but it shows me time.
How to do Get-Date to show me this format 2018-01-10 and that does not show the time?
I was currently using Get-Format s but it shows me time.
There are several ways to do this. For instance you could use the -Format parameter of the cmdlet:
Get-Date -Format 'yyyy-MM-dd'
You could use the ToString() method of the DateTime object the cmdlet produces:
(Get-Date).ToString('yyyy-MM-dd')
You could also use PowerShell's format operator (-f):
'{0:yyyy-MM-dd}' -f (Get-Date)
Powershell Script to get date as requested
get-date -Format yyyy-MM-dd
Following doc will give you brief explanation on formats