Powershell 将字符串转换为日期时间格式
我正在使用powershell将csv导入excel。我的两个列的日期时间格式如下:Powershell 将字符串转换为日期时间格式,powershell,date,Powershell,Date,我正在使用powershell将csv导入excel。我的两个列的日期时间格式如下: 2019-01-25T19:58:28.000Z 我想将该列转换为以下格式“dd/MM/yyyy h:MM” 我尝试了以下两种方法,但均无效: [datetime]::ParseExact($fullinfo.A,“dd/MM/yyyyy h:MM”,$null) $excel.Columns.item('b').NumberFormat=“dd/MM/yyyy h:MM” 这将生成所需格式的输出 $Input
2019-01-25T19:58:28.000Z
我想将该列转换为以下格式“dd/MM/yyyy h:MM”
我尝试了以下两种方法,但均无效:
[datetime]::ParseExact($fullinfo.A,“dd/MM/yyyyy h:MM”,$null)
$excel.Columns.item('b').NumberFormat=“dd/MM/yyyy h:MM”
这将生成所需格式的输出
$InputDate = '2019-01-25T19:58:28.000Z'
get-date $InputDate -Format 'dd/MM/yyyy h:mm'
非常感谢。你知道如何将am/pm设置为这种格式吗?我不在电脑上测试,但我想你应该在格式字符串中添加“tt”
$InputDate = '2019-01-25T19:58:28.000Z'
get-date $InputDate -Format 'dd/MM/yyyy h:mm'