PowerTip of the DayCreating Relative Dates

原文地址:http://powershell.com/cs/blogs/tips/archive/2010/06/11/creating-relative-dates.aspx

原文:

To create relative dates like "10 days ago," there are two paths. Administrators often add or remove time spans created by New-Timespan:

(Get-Date) - (New-TimeSpan -days 10)

Developers prefer object methods:

(Get-Date).AddDays(-10)

Both approaches will yield you the same result.

 

翻译:

创建相对日期类型

创建一个类似10天之前的日期类型,管理员通常是通过New-Timespan方法来增加或者减少时间段的方法来实现:

(Get-Date) - (New-TimeSpan -days 10)

而以下是开发人员常用的方法:

(Get-Date).AddDays(-10)

两种方法的效果都是一样的。

 

 

笔记:

powershell和很.net的方法的对比。个人还是倾向于后者。

原文地址:https://www.cnblogs.com/aspnetx/p/1756788.html