ParseExact: convert a string to DateTime
Easily convert a string to datetime format:
# Example 1
$temp = "20231030"
$myDateTime = [datetime]::ParseExact($temp, "yyyyMMdd", $null)
$myDateTime
# output:
#
# Monday, October 30, 2023 12:00:00 AM
#
# Example 2
$myDateTime = [datetime]( (Get-Date -Format "yyyy.MM.dd") + " " + "21:15:00" )
$myDateTime
# output:
#
# Monday, October 30, 2023 9:15:00 PM
#
# Example 3
$myDateTime = [datetime]( Get-Date -Year "2023" -Month "10" -Day "30" -Hour "14" -Minute "30" -Second "0" )
$myDateTime
# output:
#
# Monday, October 30, 2023 2:30:00 PM
#
# Example 4
$temp = "Sunday, 29. October 2023 22:00:09"
$culturInfo = [System.Globalization.CultureInfo]::GetCultureInfo('en-EN')
$myDateTime = [datetime]::ParseExact($temp, 'dddd, d. MMMM yyyy HH:mm:ss', $cultureInfo)
# output:
#
# Sunday, October 29, 2023 10:00:09 PM
# (in the display language of the computer!)
# e.g. Sonntag, 29. Oktober 2023 22:00:09
#PowerShellAnother useful post for reverse converting: DateTime to string.

