Calculate time difference in PowerShell

visibility 285 access_time 4 years ago languageEnglish timeline Stats
timeline Stats
Page index 0.26

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"
info Last modified by Raymond 4 years ago copyright This page is subject to Site terms.

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts

More from Kontext
Calculate Time Difference between Dates in PowerShell
visibility 29,459
thumb_up 1
access_time 5 years ago
Script to Start Multiple Virtual Machines
visibility 704
thumb_up 0
access_time 5 years ago