Monthly Archive


Get-Date format

A common question revolves around Get-Date format. In other words how can you format the output of Get-Date.

Standard output is

PS> Get-Date

27 February 2018 16:02:13


You can use –DisplayHint to control what’s displayed

PS> Get-Date -DisplayHint Date

27 February 2018

PS> Get-Date -DisplayHint Time


PS> Get-Date -DisplayHint DateTime

27 February 2018 16:03:17


Which is fine if you just want the date or the time

You’ve also got some methods on the DateTime object that can help

PS> (Get-Date).ToShortDateString()
PS> (Get-Date).ToShortTimeString()
PS> (Get-Date).ToLongDateString()
27 February 2018
PS> (Get-Date).ToLongTimeString()
PS> (Get-Date).ToFileTime()
PS> (Get-Date).ToFileTimeUtc()
PS> (Get-Date).ToUniversalTime()

27 February 2018 16:07:01


Universal Time is more properly known as Greenwich Mean Time

If you want a bit more control you can use the –Format parameter. A description of the format specifiers is available at


will give a very long list of the possible formats. Unfortunately it just displays the results not the format specifier.


There are some preset formats – for example:

PS> Get-Date -Format g
27/02/2018 16:14
PS> Get-Date -Format r
Tue, 27 Feb 2018 16:14:58 GMT
PS> Get-Date -Format s


Or you can customise the format

PS> Get-Date -Format "ddMMyyyyhhmmss"
PS> Get-Date -Format "dd/MM/yyyy hh:mm:ss"
27/02/2018 04:18:03
PS> Get-Date -Format "dd/MM/yyyy HH:mm:ss"
27/02/2018 16:18:08


Read the article at the link for the full list of options. NOTE – the options ARE case sensitive


Alternatively, you could use the –Uformat parameter to use Unix formatting. This is explained in the NOTES section of the Get-Date help file.

Some examples

PS> Get-Date -UFormat "%d/%m/%Y %r"
27/02/2018 04:23:25 PM
PS> Get-Date -UFormat "%d/%m/%Y %R"
27/02/2018 16:23


Between the display hints, the methods, –Format and –UFormat you should be able to get the date into the format you need.

Comments are closed.