I write an application in PowerShell, and I want to convert seconds to date.
In C# there is an AddS开发者_运维百科econds function that adds seconds to date. What function in PowerShell does a similar performance?
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
PS C:\> $date = Get-Date
PS C:\> $date.AddSeconds(10)
Monday, November 15, 2010 6:24:31 PM
精彩评论