Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DateTime's functions in PowerShell

I write an application in PowerShell, and I want to convert seconds to date.

In C# there is an AddSeconds function that adds seconds to date. What function in PowerShell does a similar performance?

like image 262
RRR Avatar asked Mar 06 '26 08:03

RRR


1 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 then appears to be a wrapper to the DateTime object and the following would work well:

$d3 = Get-Date 23.10.2010 -Format dd.MM.yyyy
like image 52
flq Avatar answered Mar 08 '26 06:03

flq



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!