Get-Date
Use Get-Date to return the current date and time, or convert and format a date you supply.
Documentation: Microsoft Learn — Get-Date
Syntax
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>]- Stage 1Get-Date
-Date -Format -UFormat -Year -Month -Day -DisplayHint -AsUTC
Try it
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.
Follow the objects
Run the command to inspect each stage.
Examples
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'
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
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.
Recap
Get-Date Use Get-Date to return the current date and time, or convert and format a date you supply.
Next: Get-History