February 2019
Intermediate to advanced
626 pages
15h 51m
English
The Get-Date command is the best first stop for converting strings into dates. Get-Date deals with a reasonable number of formats.
If, however, Get-Date is unable to help, the DateTime class has two static methods that may be used:
The format strings used by these methods are documented on MSDN, available at https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx.
The ParseExact method accepts one or more format strings, and returns a DateTime object:
$string = '20170102-2030' # Represents 1st February 2017, 20:30 [DateTime]::ParseExact($string, 'yyyyddMM-HHmm', (Get-Culture))
The culture, returned from Get-Culture, used previously, fills in the format provider argument.
The format string ...
Read now
Unlock full access