Powershell Powershel总和时间跨度
我怎样才能在这两个时间段内找到一些Powershell Powershel总和时间跨度,powershell,Powershell,我怎样才能在这两个时间段内找到一些 $Result1 = ($DurationVideo | Measure-Object -Property TotalMilliseconds -Sum).Sum $mts = [timespan]::FromMilliseconds($Result1) $VideoTime =("{0:hh\:mm\:ss\,fff}" -f $mts) [pscustomobject]@{'Timespan' = $VideoTime} $Res
$Result1 = ($DurationVideo | Measure-Object -Property TotalMilliseconds -Sum).Sum
$mts = [timespan]::FromMilliseconds($Result1)
$VideoTime =("{0:hh\:mm\:ss\,fff}" -f $mts)
[pscustomobject]@{'Timespan' = $VideoTime}
$Result2 = ($DurationAudio | Measure-Object -Property TotalMilliseconds -Sum).Sum
$Nts = [timespan]::FromMilliseconds($Result2)
$AudioTime =("{0:hh\:mm\:ss\,fff}" -f $Nts)
[pscustomobject]@{'Timespan' = $AudioTime}
输出:
Timespan
--------
00:10:28,631
03:55:10,000
我需要:
04:05:38,631
非常感谢您的帮助。原始变量在我看来就像timespan的:
$durationvideo + $durationaudio
您可能认为可以将其与度量对象相加,但遗憾的是,您不能:
[timespan]'1',[timespan]'1' | measure -sum # two days
Measure-Object: Input object "1.00:00:00" is not numeric.
Measure-Object: Input object "1.00:00:00" is not numeric.
只要加上它们——时髦的人可以做时间跨度数学。像这样>>
([timespan]'00:10:28.631'+[timespan]'03:55:10.000)。ToString()'你好,李,非常感谢!然而这是一个已知值,但我需要求未知值的和。在许多对象中获取的值,将提供输出。在这个案子上,我得到00:10:28631 03:55:10000,但可能是其他的。我知道了!([timespan]$Nts+[timespan]$mts).ToString()。$durationvideo+$durationaudio
谢谢js2010,工作正常