Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 将字符串转换为日期时间格式_Powershell_Date - Fatal编程技术网

Powershell 将字符串转换为日期时间格式

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

我正在使用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”


这将生成所需格式的输出

$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'