Introduction to Common properties and methods of Get-date objects in PowerShell _powershell

Source: Internet
Author: User
Tags current time

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

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.