DateTime Functions in PowerShell

I am writing an application in PowerShell and I want to convert seconds to date.

C # has an AddSeconds function that adds seconds to a date. What function in PowerShell performs similar performance?

+3
source share
2 answers

Well, since the .NET framework is right at your fingertips, you can do

$d1 = [System.DateTime]::Now

And then

$d2 = $d1.AddSeconds(30)

Get-Date is then presented as a wrapper on a DateTime object, and the following will work well:

$d3 = Get-Date 23.10.2010 -Format dd.MM.yyyy
+3
source
PS C:\> $date = Get-Date

PS C:\> $date.AddSeconds(10)

Monday, November 15, 2010 6:24:31 PM
+2
source

Source: https://habr.com/ru/post/1774948/


All Articles