Accessing Date Methods

by Dec 24, 2008

While Get-Date returns the current date and time, it really returns a DateTime object. You can use this object to find out more about the date or to calculate date and time offsets as it has a number of very useful properties and methods.

$date = Get-Date

For example, to find out if Daylight Savings Time is in effect:


Or, try adding 10 days from today:


Next, go back 5 days:


Hint: Use PowerShellPlus to get automatic code completion. Once you type the ".", you will see all the properties and methods an object exposes.