Convert Seconds To Hh:mm:ss,fff Format In PowerShell
Answer : In PowerShell 4.0 $s = "7000.6789" $ts = [timespan]::fromseconds($s) ("{0:hh\:mm\:ss\,fff}" -f $ts) Output: 01:56:40,679 In PowerShell 2.0 $s = "7000.6789" $ts = [timespan]::fromseconds($s) "{0:hh:mm:ss,fff}" -f ([datetime]$ts.Ticks) Output: 01:56:40,679 And to go back the other way... $text = "01:56:40,679" $textReformat = $text -replace ",","." $seconds = ([TimeSpan]::Parse($textReformat)).TotalSeconds $seconds Output: 7000.679 You could just use the ToString method on the TimeSpan object and specify the format you want to use. Either use one of the standard timespan formats or use a custom timespan format. For example, the following custom format gives the output you want: $ts = [timespan]::fromseconds("7000.6789") $ts.ToString("hh\:mm\:ss\,fff") This will output 01:56:40,679 Update: Updating to provide functions working in PowerShell v2 The above solution works well in PowerShe...