Convert seconds to hh:mm:ss,fff format in PowerShell -


I have a string that represents a time in seconds and milliseconds. I want to convert it to a string in the format "hh: mm: ss, fff"

There is still a flaw in my solution that less than 10 hours are shown with a decimal of two:

  ps> $ Sec = "7000.678 9" ps & gt; $ Ts = [Repeated times]: Secsands ($ s) Ps & gt; $ Res = "$ ($ ts.hours): $ ($ ts.minutes): $ ($ t.Sseconds), $ ($ ts.milliseconds)" PS & gt; $ Res PS & gt; 1: 56: 40,679  

What is the correct way to achieve this? I'm sure that -f is a more beautiful way with datetime.

in PowerShell 4.0

  $ s = "7000.6789" $ ts = [Repeatedly]: ssecond ($ s) ("{0: hH: mm \: ss \, fff}" -f $ ts)  

Output: PowerShell 2.0 $ s = "7000.6789" $ ts = [recurring times]: Sececonds ($ S) "{0: hh: mm: ss, fff}" -f ([dateimus] $ ts.Ticks)

output: 01: 56: 40,679


and return to the other side ...

  $ text = "01: 56: 40,679" $ text-refresh = $ text-clear ",", "." $ Sec = ([Timespain] :: Pars ($ text refarm) Total second second sec  

Output: 7000.679

< / Html>

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -