$timeinfo = "01-06-2017 12:34"
$template = "dd-MM-yyyy HH:mm"
[DateTime]::ParseExact($timeinfo, $template, $null)
結果:我沒有得到關於[DateTime] :: ParseExact()?
Exception calling "ParseExact" with "3" argument(s): "String was not recognized as a valid DateTime." At line:3 char:1 + [DateTime]::ParseExact($timeinfo, $template, $null) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : FormatException
我不能告訴這裏有什麼問題?爲什麼當我在模板中指定它應該讀取它時,我的字符串不是有效的日期時間?
哇,吉茲,我永遠都不會發現那個。謝謝 – user3272783
@ user3272783沒問題 - 這讓我在證書指紋中找到了答案。如果您有興趣,請添加更多信息以回答問題。考慮[接受](https://stackoverflow.com/help/accepted-answer)/ [upvoting](https://stackoverflow.com/help/why-vote)答案,如果你發現它有幫助! – gms0ulman