如何将installdate转换为其他格式?

时间:2018-07-02 19:48:25

标签: string date cmd product wmic

我正在尝试在cmd上运行此命令:

fatal: No configured push destination.

hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

joyjoko.space $ git push heroku master
The authenticity of host 'heroku.com (#####)' can't be established.
RSA key fingerprint is #####.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'heroku.com,#####' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

IPAddress可以用所需的任何地址或主机名替换。

该命令没有给我任何错误,但是,它给了我wmic:root\cli>/node:IPAddress product get name, version, vendor, installdate 格式的安装日期(例如,MMMMYYDD而不是像2017080101-Aug-2017这样的简单名称)。我试图在线寻找解决方案,但他们通常是在谈论系统安装而不是产品安装。

我知道installdate是一个字符串,所以这更多是我应该如何将该字符串转换为日期的问题。我在安装日期之后尝试使用'+%Y%m%d',但它给了我一个错误:无效的GET表达式。

1 个答案:

答案 0 :(得分:0)

如果可以使用PowerShell,这不是太困难。您可以使用Get-CimInstance -ClassName CIM_Product | Select-Object -Property @{n='Name';e={$_.Name}}, @{n='Date';e={([datetime]::ParseExact($_.InstallDate,'yyyyMMdd', $null)).ToString('dd-MMM-yyyy')}} 方法来控制所需的格式。

{{1}}