0

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.

1

3 Answers 3

3

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)
Sign up to request clarification or add additional context in comments.

Comments

0

Other method (without get-date):

[System.DateTime]::Today.ToString("yyyy-MM-dd")

Comments

0

Powershell Script to get date as requested

get-date -Format yyyy-MM-dd

Following doc will give you brief explanation on formats

https://technet.microsoft.com/en-us/library/ee692801.aspx

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.