By using this site, you acknowledge that you have read and understand our Cookie and Privacy policy. Your use of Kontext website is subject to this policy. Accept

Calculate Time Difference between Dates in PowerShell

1501 views 0 comments last modified about 12 months ago Raymond Tang

lite-log powershell

PowerShell provides a number of cmdlets to retrieve current date time and to create time span object.

Calculate time difference - CmdLets

$current = Get-Date

$end= Get-Date

$diff= New-TimeSpan -Start $current -End $end

Write-Output "Time difference is: $diff"

Output

image

The C# way

$current = [System.DateTime]::Now
$end= [System.DateTime]::Now
$diff= $end.Subtract($end)
Write-Output "Time difference is: $diff"

Output

image

Related pages

Script to Start Multiple Virtual Machines

235 views   0 comments last modified about 11 months ago

The following is a PowerShell code snippet to start multiple VMs through vmplayer.exe: # Navigate to the folder where vmplayer.exe file exists cd "D:\Program Files (x86)\VM Player" # Start the VMs by using vmplayer...

View detail

Add comment

Comments (0)

No comments yet.

Contacts

  • enquiry[at]kontext.tech

Subscribe