PowerTip: Pipe String to Get-Date


Summary: Pipe a string to the Windows PowerShell Get-Date cmdlet to convert it to a DateTime object.

Hey, Scripting Guy! Question How can I use Windows PowerShell to convert a date that is in a string format to a DateTime object?

Hey, Scripting Guy! Answer Create a pipeline, for example:

"11/14/2015" | get-date 

Comments (2)

  1. Dan P. says:

    [datetime]"11/14/2015"

  2. James Brown says:

    Indeed. I’d much rather end with a variable I can work with rather than just a console display:

    $newdate = [datetime]"11/14/2015"

Skip to main content