In a script I was writing a time stamp to a file, when the script ran again I wanted to check that the time was more than 24 hours. I used the following to convert the string back to a datetime.
1 2 3 | $dateTime = get-date -Format yyyyMMddhhmmss [datetime]::ParseExact($dateTime,"yyyyMMddhhmmss",$null) |
Source: http://msdn.microsoft.com/en-us/library/w2sa9yss.aspx