【发布时间】:2017-07-19 23:00:20
【问题描述】:
$timeinfo = "01-06-2017 12:34"
$template = "dd-MM-yyyy HH:mm"
[DateTime]::ParseExact($timeinfo, $template, $null)
结果:
使用“3”参数调用“ParseExact”的异常:“无法识别字符串 作为有效的日期时间。” 在行:3 字符:1 + [日期时间]::ParseExact($timeinfo, $template, $null) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : 格式异常我不知道这里出了什么问题?当我在模板中指定它应该如何读取它时,为什么我的字符串不是有效的日期时间?
【问题讨论】:
标签: powershell datetime exception format