Calculate Difference/Duration between Two Timestamps in PowerShell

Raymond Tang Raymond Tang 3500 1.56 index 5/26/2019

This code snippet shows how to calculate time differences.

In PowerShell, you can use New-TimeSpan cmdlets to calculate the time differences between two dates/timestamps.

Code snippet

$current = Get-Date
$end= Get-Date
$diff= New-TimeSpan -Start $current -End $end
Write-Output "Time difference is: $diff"
powershell

Join the Discussion

View or add your thoughts below

Comments