Powershell Convert to time

Viewed 179

I need to convert some particular string on time format.

2M37.526S - This represents 2 minutes, 37 seconds and 526 milliseconds.

I need to convert on "{0:hh:mm:ss\,fff}"

How the best way to do this? My code converts but is returning wrong order values.

My code :

     $a = '2M37.526S' -replace '[mM]',':' -replace '[.]', ':' -replace '[sS]', ''
     $ts =  [timespan]::fromseconds($a)
     ("{0:hh\:mm\:ss\,fff}" -f $ts)

Thanks for any help

1 Answers
Related