PowerShell Genie

Get-Date

Use Get-Date to return the current date and time, or convert and format a date you supply.

Command 1 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn — Get-Date

Syntax

1PS> Get-Date [[-Date] <datetime>] [-Format <String>] [-UFormat <String>] [-Year <Int32>] [-Month <Int32>] [-Day <Int32>] [-DisplayHint <DisplayHintType>] [-AsUTC] [<CommonParameters>]
See the command anatomy

Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.

Get-Date [[-Date] <datetime>] [-Format <String>] [-UFormat <String>] [-Year <Int32>] [-Month <Int32>] [-Day <Int32>] [-DisplayHint <DisplayHintType>] [-AsUTC] [<CommonParameters>]
  1. Stage 1Get-Date-Date -Format -UFormat -Year -Month -Day -DisplayHint -AsUTC

    Try it

    Windows PowerShell

    PowerShell example · browser support is limited.

    Execution scope: The full example below requires PowerShell outside this browser. You can edit this runner to use the supported practice commands; unsupported syntax returns an explanation.

    Interactive simulation · fictional data

    Examples

    Get-Date -Format 'yyyy-MM-dd'

    1PS> Get-Date -Format 'yyyy-MM-dd'
    Show reference output

    Sample output · fictional data, shaped like the real thing

    2026-09-10

    Get-Date -Format 'yyyy-MM-dd HH:mm:ss'

    1PS> Get-Date -Format 'yyyy-MM-dd HH:mm:ss'
    Show reference output

    Sample output · fictional data, shaped like the real thing

    2026-09-10 23:47:12

    Parameters

    Parameter definitions:

    • -Date
    • -Format
    • -UFormat
    • -Year
    • -Month
    • -Day
    • -DisplayHint
    • -AsUTC

    Get-Date on Microsoft Learn

    Practical use and troubleshooting

    Practical scenario: Use Get-Date when you need to return the current date and time, or convert and format a date you supply. Start with one identified target and inspect the returned values before extending the operation to a list. Keep the identity in your report so you can trace each result back to the object or path that produced it.

    Common error and fix: Culture-dependent parsing can swap day and month. Keep DateTime values for computation and choose an explicit format only at the reporting boundary. In an unattended script, capture this failure with its original error record and record which target failed. An empty result and an unsuccessful query must remain distinguishable in the final report.

    See also: Measure-Object. Get-Date reports dates and times; Measure-Object aggregates input properties. For elapsed durations, record start and end instants or use a timing facility rather than summing formatted date strings. Read the linked command before substituting it; similar names do not imply identical inputs or output.

    Get-Date reference on Microsoft Learn

    Recap

    Get-Date Use Get-Date to return the current date and time, or convert and format a date you supply.

    Next: Get-History
    Genie guideGet-Date

    Use Get-Date to return the current date and time, or convert and format a date you supply. The console below is pre-loaded — run it, then change a value and run it again.