Convert seconds to hh:mm:ss,fff format in PowerShell
问题 I have a string representing a time in seconds and milliseconds. I want to convert it to a string in the format "hh:mm:ss,fff". My solution still has the flaw that hours less than 10 are shown with one decimal instead of two: PS> $secs = "7000.6789" PS> $ts = [timespan]::fromseconds($s) PS> $res = "$($ts.hours):$($ts.minutes):$($ts.seconds),$($ts.milliseconds)" PS> $res PS> 1:56:40,679 What is the right way to achieve this? I'm sure there is a more elegant way with -f and datetime. 回答1: In