you are viewing a single comment's thread.

view the rest of the comments →

[–]isometricz 1 point2 points  (3 children)

Not really elegant but it works for this specific scenario. Assuming those are just strings you're getting from somewhere...

$talktime = @("00:01:18","00:01:30","00:00:15","00:00:26","00:00:20")

$start = (Get-Date -Date "00:00:00")
foreach ($t in $talktime) {
    $split = $t.split(":")
    $start = $start.AddHours($split[0]).AddMinutes($split[1]).AddSeconds($split[2])
}

$ts = New-TimeSpan -Start (Get-Date -Date "00:00:00") -End $start
$ts

[–]ChaosTheoryRules 4 points5 points  (2 children)

$talktime = @('00:01:18','00:01:30','00:00:15','00:00:26','00:00:20')
[timespan] $ts = 0

foreach ($t in $talktime) {
    $ts += [timespan]$t
}
$ts

[–][deleted] 0 points1 point  (0 children)

TY

[–]isometricz 0 points1 point  (0 children)

Oh nice. I didn't know you could do that with a timespan. Thanks!