access_time 3 years ago languageEnglish
more_vert

Calculate time difference in PowerShell

visibility 83 comment 0

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 3 years ago copyright This page is subject to Site terms.
Like this article?
Share on

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts

Follow Kontext

Get our latest updates on LinkedIn.

Want to contribute on Kontext to help others?

Learn more

More from Kontext

visibility 566
thumb_up 0
access_time 4 years ago
visibility 39
thumb_up 0
access_time 3 years ago
visibility 20109
thumb_up 1
access_time 4 years ago