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

info Last modified by Raymond at 3 years ago * This page is subject to Site terms.

More from Kontext

local_offer spark local_offer pyspark

visibility 3981
thumb_up 0
access_time 13 months ago

When creating Spark date frame using schemas, you may encounter errors about “field **: **Type can not accept object ** in type <class '*'>”. The actual error can vary, for instances, the following are some examples: field xxx: BooleanType can not accept object 100 in type ...

open_in_new Spark + PySpark

local_offer powershell

visibility 20
thumb_up 0
access_time 8 months ago

Environment variables are commonly used in many frameworks or programs.

open_in_new Code snippets

local_offer powershell

visibility 43
thumb_up 0
access_time 8 months ago

This code snippet shows how to calculate time differences.

open_in_new Code snippets

local_offer hive

visibility 1688
thumb_up 0
access_time 2 years ago

Since Hive 3.x, new authentication feature for HiveServer2 client is added. When starting HiveServer2 service (Hive version 3.0.0), you may encounter errors like: ‘HiveServer2 metastore.RetryingMetaStoreClient: RetryingMetaStoreClient trying reconnect as [username]  (auth:S...

open_in_new Hadoop

info About author

comment Comments (0)

comment Add comment

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts

No comments yet.

Dark theme mode

Dark theme mode is available on Kontext.

Learn more arrow_forward

Kontext Column

Created for everyone to publish data, programming and cloud related articles. Follow three steps to create your columns.


Learn more arrow_forward