OT: convert Convergence Time

Welcome Forums General PowerShell Q&A OT: convert Convergence Time

This topic contains 1 reply, has 2 voices, and was last updated by

 
Participant
1 year, 3 months ago.

  • Author
    Posts
  • #78593

    Participant
    Points: 71
    Rank: Member

    Sorry about the off topic but can anyone advise how I could convert (with powershell!) this Convergence Time value for AD repl?

    PT13M14.1445641S

    thanks

  • #78605

    Participant
    Points: 0
    Rank: Member

    Hi Jeff, it would help if you explain how you got this time value and what the parts represent. Taking a wild guess I'm thinking 13 minutes, 14 seconds, 1445641 10 millionths of a second. I assume you mean convert it into a timespan, but you really did not say what you wanted to convert it into.

    You could do something like this.

    $timestamp = "PT13M14.1445641S"
    (Select-String -InputObject $timestamp -Pattern "^(\d*?)PT(\d*?)M(\d*?)\.(\d*?)S$").Matches |
    ForEach-Object {
        [System.TimeSpan]::FromMinutes($_.Groups[2].value) +
        [System.TimeSpan]::FromSeconds($_.Groups[3].value) +
        [System.TimeSpan]::FromMilliseconds([math]::Round($_.Groups[4].value/10000))
    }

The topic ‘OT: convert Convergence Time’ is closed to new replies.