Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.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 更改Get进程时间戳的格式_Powershell_Format - Fatal编程技术网

Powershell 更改Get进程时间戳的格式

Powershell 更改Get进程时间戳的格式,powershell,format,Powershell,Format,我正在运行以下Powershell命令以获取tomcat服务的启动时间: Get-Process Tomcat8 | Select-Object starttime | Out-File c:\uptime.txt 它输出以下响应,这很好 StartTime --------- 19/11/2015 08:40:25 我想知道是否可以将日期/时间戳以不同的格式传输到文件中?只有那一行 理想情况下,我想要的格式是 'nov,18,2015,14:50:00' 我相信会是:嗯,日,年,hh:m

我正在运行以下Powershell命令以获取tomcat服务的启动时间:

Get-Process Tomcat8 | Select-Object starttime | Out-File c:\uptime.txt
它输出以下响应,这很好

StartTime
---------
19/11/2015 08:40:25
我想知道是否可以将日期/时间戳以不同的格式传输到文件中?只有那一行

理想情况下,我想要的格式是

'nov,18,2015,14:50:00'
我相信会是:嗯,日,年,hh:mm:ss


有没有一种方法可以让我在一条线上完成这一切

Get Process Tomcat8 |%starttime |%tostring“\'MMM,dd,yyyy,hh:mm:ss\”([cultureinfo]::InvariantCulture)|输出文件c:\uptime.txt
Perfect,谢谢。我正在尝试开始。toString
%toString
?这是一个别名吗?@sodawillow
%
是每个对象的别名,
tostring
是一个方法名。如果理解得好,它相当于
Get Process Tomcat8%{$.StartTime}%{$.tostring(\'mm,dd,yyyy,hh:mm:ss\',[cultureinfo]::InvariantCulture)}Out文件:\c uptime.txt
。我不知道你可以在PowerShell中进行这么多操作,非常感谢。
Get Process Tomcat8 |%starttime |%tostring“\'mm,dd,yyyy,hh:mm:ss\”([cultureinfo]::InvariantCulture)| Out文件c:\uptime.txt
Perfect,谢谢。我正在尝试开始。toString
%toString
?这是一个别名吗?@sodawillow
%
是每个对象的别名,
tostring
是一个方法名。如果理解得好,它相当于
Get Process Tomcat8%{$.StartTime}%{$.tostring(\'mm,dd,yyyy,hh:mm:ss\',[cultureinfo]::InvariantCulture)}Out文件:\c uptime.txt
。我不知道你能在PowerShell里玩这么多,非常感谢。