• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 8565
  • Last Modified:

Powershell - convert string to a datetime

Hi,

How can i convert a string of the format like the following:

25/07/2014 5:05:57 PM

To a datetime?

Thanks,

Ward
0
whorsfall
Asked:
whorsfall
2 Solutions
 
oBdACommented:
$SomeDateTime = Get-Date -Date "25/07/2014 5:05:57 PM"

Open in new window

0
 
SubsunCommented:
Try..
$date = [datetime]::ParseExact("25/07/2014 5:05:57 PM", "dd/MM/yyyy h:mm:ss tt", $null)

Open in new window

0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now