February 2019
Intermediate to advanced
626 pages
15h 51m
English
A date object can be changed in a number of ways.
A Timespan object can be added to or subtracted from a date:
(Get-Date) + (New-Timespan -Hours 6)
The Date property can be used, representing the start of the day:
(Get-Date).Date
The Add<Interval> methods can be used to add and subtract time, as follows:
(Get-Date).AddDays(1) # One day from now (Get-Date).AddDays(-1) # One day before now
In addition to AddDays, the DateTime object makes the following available:
(Get-Date).AddTicks(1) (Get-Date).AddMilliseconds(1) (Get-Date).AddSeconds(1) (Get-Date).AddMinutes(1) (Get-Date).AddHours(1) (Get-Date).AddMonths(1) (Get-Date).AddYears(1)
By default, dates returned by Get-Date are local (that is, within the context of the current ...
Read now
Unlock full access