This paper introduces the properties and methods of the date objects obtained by using Get-date in PowerShell, and makes good use of these objects and methods, which can greatly enhance the flexibility of our development.
Using Get-date, you can get a time object, which is not just a simple way to output the current time. Let's take a look at its properties and methods, don't look at the white.
To see the members of an object (that is, the object's properties and methods), you can use a pipe character, plus get-member this cmdlet. It's very convenient!
Copy Code code as follows:
PS c:\users\zhanghong> Get-date | Get-member
TypeName:System.DateTime
Name MemberType Definition
---- ---------- ----------
Add Method System.DateTime Add (System.TimeSpan value)
AddDays method System.DateTime AddDays (double value)
AddHours method System.DateTime addhours (double value)
......
I will not list the following. I'll write some of the more common methods and properties.
The following string of methods is used to calculate the relative time, and the number can be positive or negative. You know!
Addyears, Addmonths, AddDays, AddHours, AddMinutes, AddSeconds, Addmilliseconds, addticks
This string of properties is used to get a part of the time.
Year, Month, Day, Hour, Minute, Second, millisecond, Ticks
The following two properties, you look at the name to know what it means, very useful ah! Hurry up and collect!
DayOfWeek, DayOfYear
Others also have some attributes and methods, small weave is too lazy, do not enumerate.
About the properties and methods of Get-date objects in PowerShell, this article introduces so, hope to help everyone, thank you!