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
Date 在PowerShell中格式化日期月份_Date_Powershell_Format - Fatal编程技术网

Date 在PowerShell中格式化日期月份

Date 在PowerShell中格式化日期月份,date,powershell,format,Date,Powershell,Format,我需要将上一个日期格式化为yyyy-mm-dd 例如,今天是2016年5月25日。因此,我需要输出“2016-05-24” $a = (Get-Date).AddDays(-1).ToString('yyyy-mm-dd') Write-Output $a 当我运行代码时,我得到了不正确的2016-44-24 我该怎么做?mm指定分钟,从00到59 您必须改为使用: (Get-Date).AddDays(-1).ToString('yyyy-MM-dd')

我需要将上一个日期格式化为
yyyy-mm-dd

例如,今天是2016年5月25日。因此,我需要输出“
2016-05-24

$a = (Get-Date).AddDays(-1).ToString('yyyy-mm-dd')
Write-Output $a
当我运行代码时,我得到了不正确的
2016-44-24


我该怎么做?

mm
指定
分钟,从00到59

您必须改为使用:

(Get-Date).AddDays(-1).ToString('yyyy-MM-dd')