我需要一些帮助来弄清楚在PowerShell中将字符串转换为DateTime的格式语法。我尝试了许多组合,并继续获得Exception calling "ParseExact" with "3" argument(s): "String was not recognized as a valid DateTime."
我尝试使用的代码如下:
$timeinfo = '1/3/2020 9:56 AM'
$template = 'M/d/yyyy h:mm tt'
$culture = [Globalization.CultureInfo]::InvariantCulture
[DateTime]::ParseExact($timeinfo, $template, $culture)我使用了我在这里找到的语法:https://community.idera.com/database-tools/powershell/powertips/b/tips/posts/parsing-custom-datetime-formats。有人愿意告诉我我哪里做错了吗?我卡住了!非常感谢!
发布于 2020-09-03 13:48:47
试试这个,让解析器来做这项工作:
$timeinfo = '04/02/2020 02:00 PM'
[datetime]$timeinfohttps://stackoverflow.com/questions/63706181
复制相似问题