How to use the Get-Date command

The command Get-Date returns the current date and time of the system, and the result is shown in the form of long-date and long-time formats.

PowerShell Get-Date Format

If we use a Format-List cmdlet with Get-Date, we will see the full information that returns various dates and time formats. The command Get-Date returns a DateTime object. Let see the output of using the Get-Date | Format-List cmdlet:

  1. Get-Date | Format-List  
PowerShell Get-Date Format

DisplayHint

The DisplayHint parameter defines the type of information we want to display on the screen. This parameter also returns the DateTime object; however, it has three different types of formats, including Date, Time, and DateTime. The -DisplayHint parameter uses anyone from Date, Time, or DateTime at a time.

  • Date: it only returns the current date value.
  • Time: it only returns a current time value.
  • DateTime: it returns both the current date and time values.

Let see the output of using the followings cmdlets:

  1. Get-Date -DisplayHint Date  
  2. Get-Date -DisplayHint Time  
  3. Get-Date -DisplayHint DateTime  
PowerShell Get-Date Format

Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *