Today I used this function for the first time. Somehow, I have never needed this before. It is super simple and very useful though. It is basically the inverse of DateTime.ToString(“yyyy-mm-dd”). It allows you to parse a custom date/time format.

So, for example a Pound proxy log has a date in the format 12/Mar/2009:05:00:36 -0400, which isn’t a standard format in .NET. Using ParseExact, parsing it was a piece of cake.

$provider = New-Object System.Globalization.CultureInfo "en-US"
[DateTime]::ParseExact($, "dd/MMM/yyyy:hh:mm:ss zz00", $provider)