开发者

DateTime's functions in PowerShell

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜