Question: When you use the (Get-Date) cmdlet you get, for example, a nice format like in the code below. But if you use the ToString() you get it in a format, for example, 6/22/2019 2:25:34 PM

How do I convert it to a string but maintain the original formatting? 

```
(Get-Date).ToString()
6/22/2019 2:25:34 PM

vs....

Get-Date
Saturday, June 22, 2019 2:25:04 PM

```

Answer: 
Using the Universal Full format specifier (`U`) with the `ToString()` method, you can return the Universal Time as a string.

```
(Get-Date).ToString('U')

```

**Testing Date to String Conversion and Output Type:**

```
(Get-Date).ToString('U')
Saturday, June 22, 2019 3:11:51 PM
(Get-Date).ToString('U').GetType()

IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     String                                   System.Object

```

This alternative may not be the most elegant way, but it gets the job done.

```
((Get-Date).ToUniversalTime() | Out-String).Trim()

```

See [Standard Date and Time Format Strings](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings?view=netframework-4.8) for more information on how the format specifiers work.
You can pass a DateTimeFormatInfo into the ToString method.

```
[System.Globalization.DateTimeFormatInfo]::new().FullDateTimePattern

```

which gives:

```
dddd, dd MMMM yyyy HH:mm:ss

```

end:

```
(Get-Date).ToString([System.Globalization.DateTimeFormatInfo]::new().FullDateTimePattern)

```

results in:

```
Saturday, 22 June 2019 11:15:37

```